stop calling factory.getJdbcServices().getDialect() so much
This commit is contained in:
parent
48dc4662ef
commit
9a11e843e6
|
@ -51,6 +51,7 @@ import org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper;
|
||||||
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
|
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||||
import org.hibernate.query.spi.NavigablePath;
|
import org.hibernate.query.spi.NavigablePath;
|
||||||
|
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||||
import org.hibernate.sql.InFragment;
|
import org.hibernate.sql.InFragment;
|
||||||
import org.hibernate.sql.Insert;
|
import org.hibernate.sql.Insert;
|
||||||
import org.hibernate.sql.ast.SqlAstJoinType;
|
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||||
|
@ -165,6 +166,10 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
||||||
|
|
||||||
final SessionFactoryImplementor factory = creationContext.getSessionFactory();
|
final SessionFactoryImplementor factory = creationContext.getSessionFactory();
|
||||||
|
final JdbcServices jdbcServices = factory.getServiceRegistry().getService( JdbcServices.class );
|
||||||
|
final Dialect dialect = jdbcServices.getJdbcEnvironment().getDialect();
|
||||||
|
final SqmFunctionRegistry sqmFunctionRegistry = factory.getQueryEngine().getSqmFunctionRegistry();
|
||||||
|
|
||||||
|
|
||||||
// DISCRIMINATOR
|
// DISCRIMINATOR
|
||||||
|
|
||||||
|
@ -179,8 +184,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( dialect );
|
||||||
discriminatorAlias = column.getAlias( factory.getJdbcServices().getDialect(), persistentClass.getRootTable() );
|
discriminatorAlias = column.getAlias( dialect, persistentClass.getRootTable() );
|
||||||
}
|
}
|
||||||
discriminatorType = (BasicType<?>) persistentClass.getDiscriminator().getType();
|
discriminatorType = (BasicType<?>) persistentClass.getDiscriminator().getType();
|
||||||
if ( persistentClass.isDiscriminatorValueNull() ) {
|
if ( persistentClass.isDiscriminatorValueNull() ) {
|
||||||
|
@ -199,7 +204,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
.getJdbcLiteralFormatter( discriminatorType.getJavaTypeDescriptor() );
|
.getJdbcLiteralFormatter( discriminatorType.getJavaTypeDescriptor() );
|
||||||
discriminatorSQLString = literalFormatter.toJdbcLiteral(
|
discriminatorSQLString = literalFormatter.toJdbcLiteral(
|
||||||
discriminatorValue,
|
discriminatorValue,
|
||||||
factory.getJdbcServices().getDialect(),
|
dialect,
|
||||||
factory.getWrapperOptions()
|
factory.getWrapperOptions()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -262,17 +267,14 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
List<Column> columns = key.getColumns();
|
List<Column> columns = key.getColumns();
|
||||||
for ( int k = 0; k < idColumnSpan; k++ ) {
|
for ( int k = 0; k < idColumnSpan; k++ ) {
|
||||||
Column column = columns.get(k);
|
Column column = columns.get(k);
|
||||||
keyCols[k] = column.getQuotedName( factory.getJdbcServices().getDialect() );
|
keyCols[k] = column.getQuotedName( dialect );
|
||||||
keyColReaders[k] = column.getReadExpr( factory.getJdbcServices().getDialect() );
|
keyColReaders[k] = column.getReadExpr( dialect );
|
||||||
keyColReaderTemplates[k] = column.getTemplate(
|
keyColReaderTemplates[k] = column.getTemplate( dialect, sqmFunctionRegistry );
|
||||||
factory.getJdbcServices().getDialect(),
|
|
||||||
factory.getQueryEngine().getSqmFunctionRegistry()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
keyColumns.add( keyCols );
|
keyColumns.add( keyCols );
|
||||||
keyColumnReaders.add( keyColReaders );
|
keyColumnReaders.add( keyColReaders );
|
||||||
keyColumnReaderTemplates.add( keyColReaderTemplates );
|
keyColumnReaderTemplates.add( keyColReaderTemplates );
|
||||||
cascadeDeletes.add( key.isCascadeDeleteEnabled() && factory.getJdbcServices().getDialect().supportsCascadeDelete() );
|
cascadeDeletes.add( key.isCascadeDeleteEnabled() && dialect.supportsCascadeDelete() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//Span of the tableNames directly mapped by this entity and super-classes, if any
|
//Span of the tableNames directly mapped by this entity and super-classes, if any
|
||||||
|
@ -301,14 +303,14 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
List<Column> columns = key.getColumns();
|
List<Column> columns = key.getColumns();
|
||||||
for ( int k = 0; k < joinIdColumnSpan; k++ ) {
|
for ( int k = 0; k < joinIdColumnSpan; k++ ) {
|
||||||
Column column = columns.get(k);
|
Column column = columns.get(k);
|
||||||
keyCols[k] = column.getQuotedName( factory.getJdbcServices().getDialect() );
|
keyCols[k] = column.getQuotedName( dialect );
|
||||||
keyColReaders[k] = column.getReadExpr( factory.getJdbcServices().getDialect() );
|
keyColReaders[k] = column.getReadExpr( dialect );
|
||||||
keyColReaderTemplates[k] = column.getTemplate( factory.getJdbcServices().getDialect(), factory.getQueryEngine().getSqmFunctionRegistry() );
|
keyColReaderTemplates[k] = column.getTemplate( dialect, sqmFunctionRegistry );
|
||||||
}
|
}
|
||||||
keyColumns.add( keyCols );
|
keyColumns.add( keyCols );
|
||||||
keyColumnReaders.add( keyColReaders );
|
keyColumnReaders.add( keyColReaders );
|
||||||
keyColumnReaderTemplates.add( keyColReaderTemplates );
|
keyColumnReaderTemplates.add( keyColReaderTemplates );
|
||||||
cascadeDeletes.add( key.isCascadeDeleteEnabled() && factory.getJdbcServices().getDialect().supportsCascadeDelete() );
|
cascadeDeletes.add( key.isCascadeDeleteEnabled() && dialect.supportsCascadeDelete() );
|
||||||
|
|
||||||
tableIndex++;
|
tableIndex++;
|
||||||
}
|
}
|
||||||
|
@ -338,7 +340,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
String[] key = new String[idColumnSpan];
|
String[] key = new String[idColumnSpan];
|
||||||
List<Column> columns = table.getPrimaryKey().getColumns();
|
List<Column> columns = table.getPrimaryKey().getColumns();
|
||||||
for ( int k = 0; k < idColumnSpan; k++ ) {
|
for ( int k = 0; k < idColumnSpan; k++ ) {
|
||||||
key[k] = columns.get(k).getQuotedName( factory.getJdbcServices().getDialect() );
|
key[k] = columns.get(k).getQuotedName( dialect );
|
||||||
}
|
}
|
||||||
keyColumns.add( key );
|
keyColumns.add( key );
|
||||||
}
|
}
|
||||||
|
@ -358,7 +360,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
String[] key = new String[idColumnSpan];
|
String[] key = new String[idColumnSpan];
|
||||||
List<Column> columns = joinTable.getPrimaryKey().getColumns();
|
List<Column> columns = joinTable.getPrimaryKey().getColumns();
|
||||||
for ( int k = 0; k < idColumnSpan; k++ ) {
|
for ( int k = 0; k < idColumnSpan; k++ ) {
|
||||||
key[k] = columns.get(k).getQuotedName( factory.getJdbcServices().getDialect() );
|
key[k] = columns.get(k).getQuotedName( dialect );
|
||||||
}
|
}
|
||||||
keyColumns.add( key );
|
keyColumns.add( key );
|
||||||
}
|
}
|
||||||
|
@ -483,9 +485,6 @@ 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<>();
|
||||||
|
|
|
@ -141,6 +141,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
||||||
|
|
||||||
final SessionFactoryImplementor factory = creationContext.getSessionFactory();
|
final SessionFactoryImplementor factory = creationContext.getSessionFactory();
|
||||||
|
final Dialect dialect = factory.getJdbcServices().getDialect();
|
||||||
|
|
||||||
// CLASS + TABLE
|
// CLASS + TABLE
|
||||||
|
|
||||||
|
@ -187,7 +188,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
// JOINS
|
// JOINS
|
||||||
|
|
||||||
int j = 1;
|
int j = 1;
|
||||||
final Dialect dialect = factory.getJdbcServices().getDialect();
|
|
||||||
for ( Join join : persistentClass.getJoinClosure() ) {
|
for ( Join join : persistentClass.getJoinClosure() ) {
|
||||||
qualifiedTableNames[j] = determineTableName( join.getTable() );
|
qualifiedTableNames[j] = determineTableName( join.getTable() );
|
||||||
isInverseTable[j] = join.isInverse();
|
isInverseTable[j] = join.isInverse();
|
||||||
|
@ -327,7 +327,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
.getJdbcLiteralFormatter( discriminatorType.getJavaTypeDescriptor() );
|
.getJdbcLiteralFormatter( discriminatorType.getJavaTypeDescriptor() );
|
||||||
discriminatorSQLValue = literalFormatter.toJdbcLiteral(
|
discriminatorSQLValue = literalFormatter.toJdbcLiteral(
|
||||||
discriminatorValue,
|
discriminatorValue,
|
||||||
factory.getJdbcServices().getDialect(),
|
dialect,
|
||||||
factory.getWrapperOptions()
|
factory.getWrapperOptions()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
}
|
}
|
||||||
|
|
||||||
final SessionFactoryImplementor factory = creationContext.getSessionFactory();
|
final SessionFactoryImplementor factory = creationContext.getSessionFactory();
|
||||||
|
final Dialect dialect = factory.getJdbcServices().getDialect();
|
||||||
|
|
||||||
// TABLE
|
// TABLE
|
||||||
|
|
||||||
|
@ -206,12 +207,11 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
ArrayList<String[]> keyColumns = new ArrayList<>();
|
ArrayList<String[]> keyColumns = new ArrayList<>();
|
||||||
for ( Table table : persistentClass.getSubclassTableClosure() ) {
|
for ( Table table : persistentClass.getSubclassTableClosure() ) {
|
||||||
if ( !table.isAbstractUnionTable() ) {
|
if ( !table.isAbstractUnionTable() ) {
|
||||||
final String tableName = determineTableName( table );
|
tableNames.add( determineTableName( table ) );
|
||||||
tableNames.add( tableName );
|
|
||||||
String[] key = new String[idColumnSpan];
|
String[] key = new String[idColumnSpan];
|
||||||
List<Column> columns = table.getPrimaryKey().getColumns();
|
List<Column> columns = table.getPrimaryKey().getColumns();
|
||||||
for ( int k = 0; k < idColumnSpan; k++ ) {
|
for ( int k = 0; k < idColumnSpan; k++ ) {
|
||||||
key[k] = columns.get(k).getQuotedName( factory.getJdbcServices().getDialect() );
|
key[k] = columns.get(k).getQuotedName( dialect );
|
||||||
}
|
}
|
||||||
keyColumns.add( key );
|
keyColumns.add( key );
|
||||||
}
|
}
|
||||||
|
@ -221,8 +221,8 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
constraintOrderedKeyColumnNames = ArrayHelper.to2DStringArray( keyColumns );
|
constraintOrderedKeyColumnNames = ArrayHelper.to2DStringArray( keyColumns );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
constraintOrderedTableNames = new String[] {tableName};
|
constraintOrderedTableNames = new String[] { tableName };
|
||||||
constraintOrderedKeyColumnNames = new String[][] {getIdentifierColumnNames()};
|
constraintOrderedKeyColumnNames = new String[][] { getIdentifierColumnNames() };
|
||||||
}
|
}
|
||||||
|
|
||||||
initSubclassPropertyAliasesMap( persistentClass );
|
initSubclassPropertyAliasesMap( persistentClass );
|
||||||
|
|
Loading…
Reference in New Issue