code: private void deleteByQuery(Query query, ClassDescriptor cld) throws PersistenceBrokerException
      {
          if (logger.isDebugEnabled())
          {
              logger.debug("deleteByQuery " + cld.getClassNameOfObject() + ", " + query);
          }
  
          if (query instanceof QueryBySQL)
          {
              String sql = ((QueryBySQL) query).getSql();
              this.dbAccess.executeUpdateSQL(sql, cld);
          }
          else
          {
              // if query is Identity based transform it to a criteria based query first
              if (query instanceof QueryByIdentity)
              {
                  QueryByIdentity qbi = (QueryByIdentity) query;
                  Object oid = qbi.getExampleObject();
                  // make sure it's an Identity
                  if (!(oid instanceof Identity))
                  {
                      oid = serviceIdentity().buildIdentity(oid);
                  }
                  query = referencesBroker.getPKQuery((Identity) oid);
              }
  
              if (!cld.isInterface())
              {
                  this.dbAccess.executeDelete(query, cld);
              }
  
              // if class is an extent, we have to delete all extent classes too
              String lastUsedTable = cld.getFullTableName();
              if (cld.isExtent())
              {
                  Iterator extents = getDescriptorRepository().getAllConcreteSubclassDescriptors(cld).iterator();
  
                  while (extents.hasNext())
                  {
                      ClassDescriptor extCld = (ClassDescriptor) extents.next();
  
                      // read same table only once
                      if (!extCld.getFullTableName().equals(lastUsedTable))
                      {
                          lastUsedTable = extCld.getFullTableName();
                          this.dbAccess.executeDelete(query, extCld);
                      }
                  }
              }
  
          }
      }
docs: Extent aware Delete by Query
  @param query
  @param cld
  @throws PersistenceBrokerException