Iterator iter = join.getKey().getColumnIterator();
keyColumnNames[j] = new String[ join.getKey().getColumnSpan() ];
int i = 0;
while ( iter.hasNext() ) {
Column col = (Column) iter.next();
keyColumnNames[j][i++] = col.getQuotedName( factory.getDialect() );
}
j++;
}
constraintOrderedTableNames = new String[qualifiedTableNames.length];
constraintOrderedKeyColumnNames = new String[qualifiedTableNames.length][];
for ( int i = qualifiedTableNames.length - 1, position = 0; i >= 0; i--, position++ ) {
constraintOrderedTableNames[position] = qualifiedTableNames[i];
constraintOrderedKeyColumnNames[position] = keyColumnNames[i];
}
spaces = ArrayHelper.join(
qualifiedTableNames,
ArrayHelper.toStringArray( persistentClass.getSynchronizedTables() )
);
final boolean lazyAvailable = isInstrumented(EntityMode.POJO);
boolean hasDeferred = false;
ArrayList subclassTables = new ArrayList();
ArrayList joinKeyColumns = new ArrayList();
ArrayList isConcretes = new ArrayList();
ArrayList isDeferreds = new ArrayList();
ArrayList isInverses = new ArrayList();
ArrayList isNullables = new ArrayList();
ArrayList isLazies = new ArrayList();
subclassTables.add( qualifiedTableNames[0] );
joinKeyColumns.add( getIdentifierColumnNames() );
isConcretes.add(Boolean.TRUE);
isDeferreds.add(Boolean.FALSE);
isInverses.add(Boolean.FALSE);
isNullables.add(Boolean.FALSE);
isLazies.add(Boolean.FALSE);
joinIter = persistentClass.getSubclassJoinClosureIterator();
while ( joinIter.hasNext() ) {
Join join = (Join) joinIter.next();
isConcretes.add( new Boolean( persistentClass.isClassOrSuperclassJoin(join) ) );
isDeferreds.add( new Boolean( join.isSequentialSelect() ) );
isInverses.add( new Boolean( join.isInverse() ) );
isNullables.add( new Boolean( join.isOptional() ) );
isLazies.add( new Boolean( lazyAvailable && join.isLazy() ) );
if ( join.isSequentialSelect() && !persistentClass.isClassOrSuperclassJoin(join) ) hasDeferred = true;
subclassTables.add( join.getTable().getQualifiedName(
factory.getDialect(),
factory.getSettings().getDefaultCatalogName(),
factory.getSettings().getDefaultSchemaName()
) );
Iterator iter = join.getKey().getColumnIterator();
String[] keyCols = new String[ join.getKey().getColumnSpan() ];
int i = 0;
while ( iter.hasNext() ) {
Column col = (Column) iter.next();
keyCols[i++] = col.getQuotedName( factory.getDialect() );
}
joinKeyColumns.add(keyCols);
}
subclassTableSequentialSelect = ArrayHelper.toBooleanArray(isDeferreds);
subclassTableNameClosure = ArrayHelper.toStringArray(subclassTables);
subclassTableIsLazyClosure = ArrayHelper.toBooleanArray(isLazies);
subclassTableKeyColumnClosure = ArrayHelper.to2DStringArray(joinKeyColumns);
isClassOrSuperclassTable = ArrayHelper.toBooleanArray(isConcretes);
isInverseSubclassTable = ArrayHelper.toBooleanArray(isInverses);
isNullableSubclassTable = ArrayHelper.toBooleanArray(isNullables);
hasSequentialSelects = hasDeferred;
// DISCRIMINATOR
final Object discriminatorValue;
if ( persistentClass.isPolymorphic() ) {
Value discrimValue = persistentClass.getDiscriminator();
if (discrimValue==null) {
throw new MappingException("discriminator mapping required for single table polymorphic persistence");
}
forceDiscriminator = persistentClass.isForceDiscriminator();
Selectable selectable = (Selectable) discrimValue.getColumnIterator().next();
if ( discrimValue.hasFormula() ) {
Formula formula = (Formula) selectable;
discriminatorFormula = formula.getFormula();
discriminatorFormulaTemplate = formula.getTemplate( factory.getDialect(), factory.getSqlFunctionRegistry() );
discriminatorColumnName = null;
discriminatorAlias = "clazz_";
}
else {
Column column = (Column) selectable;
discriminatorColumnName = column.getQuotedName( factory.getDialect() );
discriminatorAlias = column.getAlias( factory.getDialect(), persistentClass.getRootTable() );
discriminatorFormula = null;
discriminatorFormulaTemplate = null;
}
discriminatorType = persistentClass.getDiscriminator().getType();
if ( persistentClass.isDiscriminatorValueNull() ) {