/** Return any tables that are defined by this expression (and not its base). */
 @Override
 public List<DatabaseTable> getOwnedTables() {
   ClassDescriptor descriptor = getDescriptor();
   List<DatabaseTable> tables = null;
   if (descriptor == null) {
     List additionalTables = getAdditionalTables();
     if (additionalTables == null) {
       return null;
     } else {
       return new ArrayList(additionalTables);
     }
   } else if (descriptor.isAggregateDescriptor()) {
     return null;
   } else if ((descriptor.getHistoryPolicy() != null)
       && (getAsOfClause() != null && getAsOfClause().getValue() != null)) {
     tables = descriptor.getHistoryPolicy().getHistoricalTables();
   } else if (isUsingOuterJoinForMultitableInheritance()) {
     tables = descriptor.getInheritancePolicy().getAllTables();
   } else {
     tables = descriptor.getTables();
   }
   List additionalTables = getAdditionalTables();
   if (additionalTables != null) {
     tables = new Vector(tables);
     Helper.addAllUniqueToList(tables, additionalTables);
     return tables;
   }
   return tables;
 }
  /** PUBLIC: Add a type indicator conversion to this mapping. */
  public void addClassIndicator(Class implementer, Object typeIndicator) {
    if (typeIndicator == null) {
      typeIndicator = Helper.getNullWrapper();
    }

    getTypeIndicatorTranslation().put(implementer, typeIndicator);
    getTypeIndicatorTranslation().put(typeIndicator, implementer);
  }
  /** INTERNAL: Return the type for a specified implementor */
  protected Object getTypeForImplementor(Class implementor) {
    Object type = getTypeIndicatorTranslation().get(implementor);
    if (type == Helper.getNullWrapper()) {
      type = null;
    }

    return type;
  }
  /** INTERNAL: Return the implementor for a specified type */
  protected Object getImplementorForType(Object type, AbstractSession session) {
    if (type == null) {
      return getTypeIndicatorTranslation().get(Helper.getNullWrapper());
    }

    // Must ensure the type is the same, i.e. Integer != BigDecimal.
    try {
      type = session.getDatasourcePlatform().convertObject(type, getTypeField().getType());
    } catch (ConversionException e) {
      throw ConversionException.couldNotBeConverted(this, getDescriptor(), e);
    }

    return getTypeIndicatorTranslation().get(type);
  }
  /** INTERNAL: Set the type field classification through searching the indicators hashtable. */
  @Override
  public void preInitialize(AbstractSession session) throws DescriptorException {
    super.preInitialize(session);
    if (getTypeIndicatorTranslation().isEmpty()) {
      return;
    }
    Class type = null;
    for (Iterator typeValuesEnum = getTypeIndicatorTranslation().values().iterator();
        typeValuesEnum.hasNext() && (type == null); ) {
      Object value = typeValuesEnum.next();
      if ((value != Helper.getNullWrapper()) && (!(value instanceof Class))) {
        type = value.getClass();
      }
    }

    getTypeField().setType(type);
  }
 /**
  * INTERNAL: Add indicators by classname. For use by the Mapping Workbench to avoid classpath
  * dependencies
  */
 public void addClassNameIndicator(String className, Object typeIndicator) {
   if (typeIndicator == null) {
     typeIndicator = Helper.getNullWrapper();
   }
   getTypeIndicatorNameTranslation().put(className, typeIndicator);
 }
 /**
  * INTERNAL: Rehash any maps based on fields. This is used to clone descriptors for aggregates,
  * which hammer field names.
  */
 @Override
 public void rehashFieldDependancies(AbstractSession session) {
   setSourceToTargetQueryKeyFields(Helper.rehashMap(getSourceToTargetQueryKeyNames()));
 }