move subclassColumnClosure down to the only subclass that uses it
This commit is contained in:
parent
135216b0a9
commit
48dc4662ef
|
@ -359,7 +359,7 @@ public abstract class AbstractEntityPersister
|
||||||
private final CascadeStyle[] subclassPropertyCascadeStyleClosure;
|
private final CascadeStyle[] subclassPropertyCascadeStyleClosure;
|
||||||
|
|
||||||
//information about all columns/formulas in class hierarchy
|
//information about all columns/formulas in class hierarchy
|
||||||
private final String[] subclassColumnClosure; //only used by JoinedSubclassEntityPersister! TODO: MOVE IT DOWN!
|
// private final String[] subclassColumnClosure;
|
||||||
// private final boolean[] subclassColumnLazyClosure;
|
// private final boolean[] subclassColumnLazyClosure;
|
||||||
private final String[] subclassColumnAliasClosure;
|
private final String[] subclassColumnAliasClosure;
|
||||||
private final boolean[] subclassColumnSelectableClosure;
|
private final boolean[] subclassColumnSelectableClosure;
|
||||||
|
@ -705,12 +705,10 @@ public abstract class AbstractEntityPersister
|
||||||
|
|
||||||
this.entityMetamodel = new EntityMetamodel( bootDescriptor, this, creationContext );
|
this.entityMetamodel = new EntityMetamodel( bootDescriptor, this, creationContext );
|
||||||
|
|
||||||
if ( entityMetamodel.isMutable() ) {
|
this.entityEntryFactory = entityMetamodel.isMutable()
|
||||||
this.entityEntryFactory = MutableEntityEntryFactory.INSTANCE;
|
? MutableEntityEntryFactory.INSTANCE
|
||||||
}
|
: ImmutableEntityEntryFactory.INSTANCE;
|
||||||
else {
|
|
||||||
this.entityEntryFactory = ImmutableEntityEntryFactory.INSTANCE;
|
|
||||||
}
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
this.representationStrategy = creationContext.getBootstrapContext().getRepresentationStrategySelector()
|
this.representationStrategy = creationContext.getBootstrapContext().getRepresentationStrategySelector()
|
||||||
|
@ -719,7 +717,6 @@ public abstract class AbstractEntityPersister
|
||||||
this.javaType = representationStrategy.getLoadJavaType();
|
this.javaType = representationStrategy.getLoadJavaType();
|
||||||
assert javaType != null;
|
assert javaType != null;
|
||||||
|
|
||||||
|
|
||||||
final JdbcServices jdbcServices = factory.getServiceRegistry().getService( JdbcServices.class );
|
final JdbcServices jdbcServices = factory.getServiceRegistry().getService( JdbcServices.class );
|
||||||
final Dialect dialect = jdbcServices.getJdbcEnvironment().getDialect();
|
final Dialect dialect = jdbcServices.getJdbcEnvironment().getDialect();
|
||||||
|
|
||||||
|
@ -777,12 +774,9 @@ public abstract class AbstractEntityPersister
|
||||||
|
|
||||||
// VERSION
|
// VERSION
|
||||||
|
|
||||||
if ( bootDescriptor.isVersioned() ) {
|
versionColumnName = bootDescriptor.isVersioned()
|
||||||
versionColumnName = bootDescriptor.getVersion().getColumns().get(0).getQuotedName( dialect );
|
? bootDescriptor.getVersion().getColumns().get(0).getQuotedName(dialect)
|
||||||
}
|
: null;
|
||||||
else {
|
|
||||||
versionColumnName = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//WHERE STRING
|
//WHERE STRING
|
||||||
|
|
||||||
|
@ -846,14 +840,15 @@ public abstract class AbstractEntityPersister
|
||||||
colAliases[k] = selectable.getAlias( dialect, prop.getValue().getTable() );
|
colAliases[k] = selectable.getAlias( dialect, prop.getValue().getTable() );
|
||||||
if ( selectable.isFormula() ) {
|
if ( selectable.isFormula() ) {
|
||||||
foundFormula = true;
|
foundFormula = true;
|
||||||
( (Formula) selectable ).setFormula( substituteBrackets( ( (Formula) selectable ).getFormula() ) );
|
Formula formula = (Formula) selectable;
|
||||||
|
formula.setFormula( substituteBrackets( formula.getFormula() ) );
|
||||||
formulaTemplates[k] = selectable.getTemplate( dialect, factory.getQueryEngine().getSqmFunctionRegistry() );
|
formulaTemplates[k] = selectable.getTemplate( dialect, factory.getQueryEngine().getSqmFunctionRegistry() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Column col = (Column) selectable;
|
Column column = (Column) selectable;
|
||||||
colNames[k] = col.getQuotedName( dialect );
|
colNames[k] = column.getQuotedName( dialect );
|
||||||
// colReaderTemplates[k] = col.getTemplate( dialect, factory.getQueryEngine().getSqmFunctionRegistry() );
|
// colReaderTemplates[k] = column.getTemplate( dialect, factory.getQueryEngine().getSqmFunctionRegistry() );
|
||||||
colWriters[k] = col.getWriteExpr();
|
colWriters[k] = column.getWriteExpr();
|
||||||
}
|
}
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
|
@ -863,7 +858,7 @@ public abstract class AbstractEntityPersister
|
||||||
propertyColumnWriters[i] = colWriters;
|
propertyColumnWriters[i] = colWriters;
|
||||||
propertyColumnAliases[i] = colAliases;
|
propertyColumnAliases[i] = colAliases;
|
||||||
|
|
||||||
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
|
final boolean lazy = !EnhancementHelper.includeInBaseFetchGroup(
|
||||||
prop,
|
prop,
|
||||||
entityMetamodel.isInstrumented(),
|
entityMetamodel.isInstrumented(),
|
||||||
entityName -> {
|
entityName -> {
|
||||||
|
@ -905,7 +900,7 @@ public abstract class AbstractEntityPersister
|
||||||
|
|
||||||
// SUBCLASS PROPERTY CLOSURE
|
// SUBCLASS PROPERTY CLOSURE
|
||||||
|
|
||||||
ArrayList<String> columns = new ArrayList<>();
|
// ArrayList<String> columns = new ArrayList<>();
|
||||||
// ArrayList<Boolean> columnsLazy = new ArrayList<>();
|
// ArrayList<Boolean> columnsLazy = new ArrayList<>();
|
||||||
// ArrayList<String> columnReaderTemplates = new ArrayList<>();
|
// ArrayList<String> columnReaderTemplates = new ArrayList<>();
|
||||||
ArrayList<String> aliases = new ArrayList<>();
|
ArrayList<String> aliases = new ArrayList<>();
|
||||||
|
@ -968,19 +963,21 @@ public abstract class AbstractEntityPersister
|
||||||
// formulasLazy.add( lazy );
|
// formulasLazy.add( lazy );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Column col = (Column) selectable;
|
Column column = (Column) selectable;
|
||||||
String colName = col.getQuotedName( dialect );
|
String colName = column.getQuotedName( dialect );
|
||||||
// colnos[l] = columns.size(); //before add :-)
|
// colnos[l] = columns.size(); //before add :-)
|
||||||
// formnos[l] = -1;
|
// formnos[l] = -1;
|
||||||
columns.add( colName );
|
// columns.add( colName );
|
||||||
cols[l] = colName;
|
cols[l] = colName;
|
||||||
aliases.add( selectable.getAlias( dialect, prop.getValue().getTable() ) );
|
aliases.add( selectable.getAlias( dialect, prop.getValue().getTable() ) );
|
||||||
// columnsLazy.add( lazy );
|
// columnsLazy.add( lazy );
|
||||||
columnSelectables.add( prop.isSelectable() );
|
columnSelectables.add( prop.isSelectable() );
|
||||||
|
|
||||||
readers[l] = col.getReadExpr( dialect );
|
readers[l] = column.getReadExpr( dialect );
|
||||||
String readerTemplate = col.getTemplate( dialect, factory.getQueryEngine().getSqmFunctionRegistry() );
|
readerTemplates[l] = column.getTemplate(
|
||||||
readerTemplates[l] = readerTemplate;
|
dialect,
|
||||||
|
factory.getQueryEngine().getSqmFunctionRegistry()
|
||||||
|
);
|
||||||
// columnReaderTemplates.add( readerTemplate );
|
// columnReaderTemplates.add( readerTemplate );
|
||||||
}
|
}
|
||||||
l++;
|
l++;
|
||||||
|
@ -995,7 +992,7 @@ public abstract class AbstractEntityPersister
|
||||||
joinedFetchesList.add( prop.getValue().getFetchMode() );
|
joinedFetchesList.add( prop.getValue().getFetchMode() );
|
||||||
cascades.add( prop.getCascadeStyle() );
|
cascades.add( prop.getCascadeStyle() );
|
||||||
}
|
}
|
||||||
subclassColumnClosure = ArrayHelper.toStringArray( columns );
|
// subclassColumnClosure = ArrayHelper.toStringArray( columns );
|
||||||
subclassColumnAliasClosure = ArrayHelper.toStringArray( aliases );
|
subclassColumnAliasClosure = ArrayHelper.toStringArray( aliases );
|
||||||
// subclassColumnLazyClosure = ArrayHelper.toBooleanArray( columnsLazy );
|
// subclassColumnLazyClosure = ArrayHelper.toBooleanArray( columnsLazy );
|
||||||
subclassColumnSelectableClosure = ArrayHelper.toBooleanArray( columnSelectables );
|
subclassColumnSelectableClosure = ArrayHelper.toBooleanArray( columnSelectables );
|
||||||
|
@ -2509,11 +2506,6 @@ public abstract class AbstractEntityPersister
|
||||||
return ArrayHelper.toIntArray( fields );
|
return ArrayHelper.toIntArray( fields );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated //TODO: REMOVE THIS
|
|
||||||
protected String[] getSubclassColumnClosure() {
|
|
||||||
return subclassColumnClosure;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String[] getSubclassColumnAliasClosure() {
|
protected String[] getSubclassColumnAliasClosure() {
|
||||||
return subclassColumnAliasClosure;
|
return subclassColumnAliasClosure;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.cache.spi.access.EntityDataAccess;
|
import org.hibernate.cache.spi.access.EntityDataAccess;
|
||||||
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
|
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
|
||||||
|
import org.hibernate.dialect.Dialect;
|
||||||
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.internal.DynamicFilterAliasGenerator;
|
import org.hibernate.internal.DynamicFilterAliasGenerator;
|
||||||
|
@ -118,6 +120,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
// subclasses and superclasses of this class
|
// subclasses and superclasses of this class
|
||||||
private final int[] subclassColumnTableNumberClosure;
|
private final int[] subclassColumnTableNumberClosure;
|
||||||
// private final int[] subclassFormulaTableNumberClosure;
|
// private final int[] subclassFormulaTableNumberClosure;
|
||||||
|
private final String[] subclassColumnClosure;
|
||||||
|
|
||||||
private final boolean[] subclassTableSequentialSelect;
|
private final boolean[] subclassTableSequentialSelect;
|
||||||
// private final boolean[] subclassTableIsLazyClosure;
|
// private final boolean[] subclassTableIsLazyClosure;
|
||||||
|
@ -176,8 +179,8 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final Column column = (Column) selectable;
|
final Column column = (Column) selectable;
|
||||||
explicitDiscriminatorColumnName = column.getQuotedName(factory.getJdbcServices().getDialect());
|
explicitDiscriminatorColumnName = column.getQuotedName( factory.getJdbcServices().getDialect() );
|
||||||
discriminatorAlias = column.getAlias(factory.getJdbcServices().getDialect(), persistentClass.getRootTable() );
|
discriminatorAlias = column.getAlias( factory.getJdbcServices().getDialect(), persistentClass.getRootTable() );
|
||||||
}
|
}
|
||||||
discriminatorType = (BasicType<?>) persistentClass.getDiscriminator().getType();
|
discriminatorType = (BasicType<?>) persistentClass.getDiscriminator().getType();
|
||||||
if ( persistentClass.isDiscriminatorValueNull() ) {
|
if ( persistentClass.isDiscriminatorValueNull() ) {
|
||||||
|
@ -480,9 +483,13 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
|
|
||||||
//TODO: code duplication with SingleTableEntityPersister
|
//TODO: code duplication with SingleTableEntityPersister
|
||||||
|
|
||||||
|
final JdbcServices jdbcServices = factory.getServiceRegistry().getService( JdbcServices.class );
|
||||||
|
final Dialect dialect = jdbcServices.getJdbcEnvironment().getDialect();
|
||||||
|
|
||||||
ArrayList<Integer> columnTableNumbers = new ArrayList<>();
|
ArrayList<Integer> columnTableNumbers = new ArrayList<>();
|
||||||
// ArrayList<Integer> formulaTableNumbers = new ArrayList<>();
|
// ArrayList<Integer> formulaTableNumbers = new ArrayList<>();
|
||||||
ArrayList<Integer> propTableNumbers = new ArrayList<>();
|
ArrayList<Integer> propTableNumbers = new ArrayList<>();
|
||||||
|
ArrayList<String> columns = new ArrayList<>();
|
||||||
|
|
||||||
for ( Property property : persistentClass.getSubclassPropertyClosure() ) {
|
for ( Property property : persistentClass.getSubclassPropertyClosure() ) {
|
||||||
Table table = property.getValue().getTable();
|
Table table = property.getValue().getTable();
|
||||||
|
@ -498,14 +505,16 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
columnTableNumbers.add( tableNumber );
|
columnTableNumbers.add( tableNumber );
|
||||||
|
Column column = (Column) selectable;
|
||||||
|
columns.add( column.getQuotedName( dialect ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subclassColumnTableNumberClosure = ArrayHelper.toIntArray( columnTableNumbers );
|
subclassColumnTableNumberClosure = ArrayHelper.toIntArray( columnTableNumbers );
|
||||||
subclassPropertyTableNumberClosure = ArrayHelper.toIntArray( propTableNumbers );
|
subclassPropertyTableNumberClosure = ArrayHelper.toIntArray( propTableNumbers );
|
||||||
// subclassFormulaTableNumberClosure = ArrayHelper.toIntArray( formulaTableNumbers );
|
// subclassFormulaTableNumberClosure = ArrayHelper.toIntArray( formulaTableNumbers );
|
||||||
|
subclassColumnClosure = ArrayHelper.toStringArray( columns );
|
||||||
|
|
||||||
// SUBCLASSES
|
// SUBCLASSES
|
||||||
|
|
||||||
|
@ -596,9 +605,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
initDiscriminatorProperties( factory, k, table, discriminatorValue );
|
initDiscriminatorProperties( factory, k, table, discriminatorValue );
|
||||||
subclassesByDiscriminatorValue.put( discriminatorValue, subclass.getEntityName() );
|
subclassesByDiscriminatorValue.put( discriminatorValue, subclass.getEntityName() );
|
||||||
int id = getTableId(
|
int id = getTableId(
|
||||||
table.getQualifiedName(
|
table.getQualifiedName( factory.getSqlStringGenerationContext() ),
|
||||||
factory.getSqlStringGenerationContext()
|
|
||||||
),
|
|
||||||
subclassTableNameClosure
|
subclassTableNameClosure
|
||||||
);
|
);
|
||||||
notNullColumnTableNumbers[k] = id;
|
notNullColumnTableNumbers[k] = id;
|
||||||
|
@ -673,7 +680,9 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
*
|
*
|
||||||
* @return subclassNamesBySubclassTable
|
* @return subclassNamesBySubclassTable
|
||||||
*/
|
*/
|
||||||
private String[][] buildSubclassNamesBySubclassTableMapping(PersistentClass persistentClass, SessionFactoryImplementor factory) {
|
private String[][] buildSubclassNamesBySubclassTableMapping(
|
||||||
|
PersistentClass persistentClass,
|
||||||
|
SessionFactoryImplementor factory) {
|
||||||
// this value represents the number of subclasses (and not the class itself)
|
// this value represents the number of subclasses (and not the class itself)
|
||||||
final int numberOfSubclassTables = subclassTableNameClosure.length - coreTableSpan;
|
final int numberOfSubclassTables = subclassTableNameClosure.length - coreTableSpan;
|
||||||
if ( numberOfSubclassTables == 0 ) {
|
if ( numberOfSubclassTables == 0 ) {
|
||||||
|
@ -1107,18 +1116,17 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
return naturalOrderPropertyTableNumbers[i];
|
return naturalOrderPropertyTableNumbers[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String[] subclassColumnNameClosure = getSubclassColumnClosure();
|
for (int i = 0, max = subclassColumnClosure.length; i < max; i++ ) {
|
||||||
for ( int i = 0, max = subclassColumnNameClosure.length; i < max; i++ ) {
|
final boolean quoted = subclassColumnClosure[i].startsWith( "\"" )
|
||||||
final boolean quoted = subclassColumnNameClosure[i].startsWith( "\"" )
|
&& subclassColumnClosure[i].endsWith( "\"" );
|
||||||
&& subclassColumnNameClosure[i].endsWith( "\"" );
|
|
||||||
if ( quoted ) {
|
if ( quoted ) {
|
||||||
if ( subclassColumnNameClosure[i].equals( columnName ) ) {
|
if ( subclassColumnClosure[i].equals( columnName ) ) {
|
||||||
return subclassColumnTableNumberClosure[i];
|
return subclassColumnTableNumberClosure[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( subclassColumnNameClosure[i].equalsIgnoreCase( columnName ) ) {
|
if ( subclassColumnClosure[i].equalsIgnoreCase( columnName ) ) {
|
||||||
return subclassColumnTableNumberClosure[i];
|
return subclassColumnTableNumberClosure[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue