eliminate casts to AbstractEntityPersister

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-06-03 00:03:30 +02:00 committed by Steve Ebersole
parent ebc253a6f9
commit 61a00b1e6c
35 changed files with 548 additions and 275 deletions

View File

@ -115,9 +115,7 @@ public class WrapVisitor extends ProxyVisitor {
&& ((LazyAttributeLoadingInterceptor)attributeInterceptor).isAttributeLoaded( persister.getAttributeMapping().getAttributeName() ) ) { && ((LazyAttributeLoadingInterceptor)attributeInterceptor).isAttributeLoaded( persister.getAttributeMapping().getAttributeName() ) ) {
final EntityEntry entry = persistenceContext.getEntry( entity ); final EntityEntry entry = persistenceContext.getEntry( entity );
if ( entry.isExistsInDatabase() ) { if ( entry.isExistsInDatabase() ) {
final AbstractEntityPersister entityDescriptor = final Object key = AbstractEntityPersister.getCollectionKey(
(AbstractEntityPersister) persister.getOwnerEntityPersister();
final Object key = entityDescriptor.getCollectionKey(
persister, persister,
entity, entity,
entry, entry,

View File

@ -60,7 +60,6 @@ import org.hibernate.metamodel.mapping.ValuedModelPart;
import org.hibernate.metamodel.mapping.VirtualModelPart; import org.hibernate.metamodel.mapping.VirtualModelPart;
import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.persister.collection.AbstractCollectionPersister; import org.hibernate.persister.collection.AbstractCollectionPersister;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityNameUse; import org.hibernate.persister.entity.EntityNameUse;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.JoinedSubclassEntityPersister; import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
@ -360,12 +359,11 @@ public class ToOneAttributeMapping
isKeyTableNullable = !persister.getTableName().equals( targetTableName ); isKeyTableNullable = !persister.getTableName().equals( targetTableName );
} }
else { else {
final AbstractEntityPersister persister = (AbstractEntityPersister) declaringEntityPersister;
final int tableIndex = ArrayHelper.indexOf( final int tableIndex = ArrayHelper.indexOf(
persister.getTableNames(), declaringEntityPersister.getTableNames(),
targetTableName targetTableName
); );
isKeyTableNullable = persister.isNullableTable( tableIndex ); isKeyTableNullable = declaringEntityPersister.isNullableTable( tableIndex );
} }
} }
isOptional = ( (ManyToOne) bootValue ).isIgnoreNotFound(); isOptional = ( (ManyToOne) bootValue ).isIgnoreNotFound();
@ -728,8 +726,8 @@ public class ToOneAttributeMapping
} }
static String findMapsIdPropertyName(EntityMappingType entityMappingType, String referencedPropertyName) { static String findMapsIdPropertyName(EntityMappingType entityMappingType, String referencedPropertyName) {
final AbstractEntityPersister persister = (AbstractEntityPersister) entityMappingType.getEntityPersister(); final EntityPersister persister = entityMappingType.getEntityPersister();
if ( Arrays.equals( persister.getKeyColumnNames(), persister.getPropertyColumnNames( referencedPropertyName ) ) ) { if ( Arrays.equals( persister.getIdentifierColumnNames(), persister.getPropertyColumnNames( referencedPropertyName ) ) ) {
return persister.getIdentifierPropertyName(); return persister.getIdentifierPropertyName();
} }
return null; return null;

View File

@ -11,7 +11,7 @@ import org.hibernate.metamodel.mapping.MappingType;
import org.hibernate.metamodel.mapping.ModelPartContainer; import org.hibernate.metamodel.mapping.ModelPartContainer;
import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.metamodel.mapping.ordering.TranslationContext; import org.hibernate.metamodel.mapping.ordering.TranslationContext;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.NullPrecedence; import org.hibernate.query.NullPrecedence;
import org.hibernate.query.SortDirection; import org.hibernate.query.SortDirection;
import org.hibernate.sql.ast.spi.SqlAstCreationState; import org.hibernate.sql.ast.spi.SqlAstCreationState;
@ -119,11 +119,9 @@ public class ColumnReference implements OrderingExpression, SequencePart {
final MappingType elementMappingType = pluralAttribute.getElementDescriptor().getPartMappingType(); final MappingType elementMappingType = pluralAttribute.getElementDescriptor().getPartMappingType();
if ( elementMappingType instanceof AbstractEntityPersister ) { if ( elementMappingType instanceof EntityPersister) {
final AbstractEntityPersister abstractEntityPersister = (AbstractEntityPersister) elementMappingType; final EntityPersister entityPersister = (EntityPersister) elementMappingType;
final int tableNumber = abstractEntityPersister.determineTableNumberForColumn( columnExpression ); final String tableName = entityPersister.getTableNameForColumn( columnExpression );
final String tableName = abstractEntityPersister.getTableName( tableNumber );
return tableGroup.getTableReference( tableGroup.getNavigablePath(), tableName ); return tableGroup.getTableReference( tableGroup.getNavigablePath(), tableName );
} }
else { else {

View File

@ -251,7 +251,6 @@ import org.hibernate.sql.ast.tree.from.StandardTableGroup;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.from.TableReferenceJoin; import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
import org.hibernate.sql.ast.tree.insert.InsertSelectStatement;
import org.hibernate.sql.ast.tree.predicate.ComparisonPredicate; import org.hibernate.sql.ast.tree.predicate.ComparisonPredicate;
import org.hibernate.sql.ast.tree.predicate.InListPredicate; import org.hibernate.sql.ast.tree.predicate.InListPredicate;
import org.hibernate.sql.ast.tree.predicate.Junction; import org.hibernate.sql.ast.tree.predicate.Junction;
@ -527,7 +526,7 @@ public abstract class AbstractEntityPersister
assert javaType != null; assert javaType != null;
this.implementsLifecycle = Lifecycle.class.isAssignableFrom( javaType.getJavaTypeClass() ); this.implementsLifecycle = Lifecycle.class.isAssignableFrom( javaType.getJavaTypeClass() );
concreteProxy = isPolymorphic() concreteProxy = entityMetamodel.isPolymorphic()
&& ( getBytecodeEnhancementMetadata().isEnhancedForLazyLoading() || hasProxy() ) && ( getBytecodeEnhancementMetadata().isEnhancedForLazyLoading() || hasProxy() )
&& persistentClass.isConcreteProxy(); && persistentClass.isConcreteProxy();
@ -942,8 +941,6 @@ public abstract class AbstractEntityPersister
return queryCacheLayout == CacheLayout.SHALLOW_WITH_DISCRIMINATOR; return queryCacheLayout == CacheLayout.SHALLOW_WITH_DISCRIMINATOR;
} }
public abstract String getSubclassTableName(int j);
protected abstract String[] getSubclassTableNames(); protected abstract String[] getSubclassTableNames();
protected abstract String[] getSubclassTableKeyColumns(int j); protected abstract String[] getSubclassTableKeyColumns(int j);
@ -966,37 +963,12 @@ public abstract class AbstractEntityPersister
return isClassOrSuperclassTable( j ); return isClassOrSuperclassTable( j );
} }
public abstract int getSubclassTableSpan();
public abstract int getTableSpan();
public abstract boolean hasDuplicateTables();
/**
* @deprecated Only ever used from places where we really want to use<ul>
* <li>{@link SelectStatement} (select generator)</li>
* <li>{@link InsertSelectStatement}</li>
* <li>{@link org.hibernate.sql.ast.tree.update.UpdateStatement}</li>
* <li>{@link org.hibernate.sql.ast.tree.delete.DeleteStatement}</li>
* </ul>
*/
@Deprecated( since = "6.2" )
public abstract String getTableName(int j);
public abstract String[] getKeyColumns(int j);
public abstract boolean isPropertyOfTable(int property, int j); public abstract boolean isPropertyOfTable(int property, int j);
protected abstract int[] getPropertyTableNumbers(); protected abstract int[] getPropertyTableNumbers();
private static final String DISCRIMINATOR_ALIAS = "clazz_"; private static final String DISCRIMINATOR_ALIAS = "clazz_";
/**
* The name of the table to use when performing mutations (INSERT,UPDATE,DELETE)
* for the given attribute
*/
public abstract String getAttributeMutationTableName(int i);
@Override @Override
public String getDiscriminatorColumnName() { public String getDiscriminatorColumnName() {
return DISCRIMINATOR_ALIAS; return DISCRIMINATOR_ALIAS;
@ -1016,10 +988,12 @@ public abstract class AbstractEntityPersister
return null; return null;
} }
@Override
public boolean isInverseTable(int j) { public boolean isInverseTable(int j) {
return false; return false;
} }
@Override
public boolean isNullableTable(int j) { public boolean isNullableTable(int j) {
return false; return false;
} }
@ -1033,6 +1007,7 @@ public abstract class AbstractEntityPersister
return entityMetamodel.getSubclassEntityNames().contains( entityName ); return entityMetamodel.getSubclassEntityNames().contains( entityName );
} }
@Override
public boolean isSharedColumn(String columnExpression) { public boolean isSharedColumn(String columnExpression) {
return sharedColumnNames.contains( columnExpression ); return sharedColumnNames.contains( columnExpression );
} }
@ -1087,6 +1062,7 @@ public abstract class AbstractEntityPersister
return rowIdName != null; return rowIdName != null;
} }
@Override
public String[] getTableNames() { public String[] getTableNames() {
final String[] tableNames = new String[getTableSpan()]; final String[] tableNames = new String[getTableSpan()];
for ( int i = 0; i < tableNames.length; i++ ) { for ( int i = 0; i < tableNames.length; i++ ) {
@ -1403,7 +1379,7 @@ public abstract class AbstractEntityPersister
generateJoinPredicate( generateJoinPredicate(
lhs, lhs,
joinedTableReference, joinedTableReference,
getKeyColumnNames(), getIdentifierColumnNames(),
targetColumns, targetColumns,
creationState creationState
) )
@ -1555,7 +1531,7 @@ public abstract class AbstractEntityPersister
} }
public @Nullable Object getCollectionKey( public @Nullable static Object getCollectionKey(
CollectionPersister persister, CollectionPersister persister,
Object owner, Object owner,
EntityEntry ownerEntry, EntityEntry ownerEntry,
@ -2275,20 +2251,20 @@ public abstract class AbstractEntityPersister
return hasFormulaProperties; return hasFormulaProperties;
} }
@Override
public FetchMode getFetchMode(int i) { public FetchMode getFetchMode(int i) {
return subclassPropertyFetchModeClosure[i]; return subclassPropertyFetchModeClosure[i];
} }
@Override
public Type getSubclassPropertyType(int i) { public Type getSubclassPropertyType(int i) {
return subclassPropertyTypeClosure[i]; return subclassPropertyTypeClosure[i];
} }
@Override
public int countSubclassProperties() { public int countSubclassProperties() {
return subclassPropertyTypeClosure.length; return subclassPropertyTypeClosure.length;
} }
@Override
public String[] getSubclassPropertyColumnNames(int i) { public String[] getSubclassPropertyColumnNames(int i) {
return subclassPropertyColumnNameClosure[i]; return subclassPropertyColumnNameClosure[i];
} }
@ -2647,17 +2623,6 @@ public abstract class AbstractEntityPersister
return select.toStatementString(); return select.toStatementString();
} }
@Internal
public boolean hasLazyDirtyFields(int[] dirtyFields) {
final boolean[] propertyLaziness = getPropertyLaziness();
for ( int i = 0; i < dirtyFields.length; i++ ) {
if ( propertyLaziness[dirtyFields[i]] ) {
return true;
}
}
return false;
}
@Override @Override
public GeneratedValuesMutationDelegate getInsertDelegate() { public GeneratedValuesMutationDelegate getInsertDelegate() {
return insertDelegate; return insertDelegate;
@ -2668,11 +2633,12 @@ public abstract class AbstractEntityPersister
return updateDelegate; return updateDelegate;
} }
protected EntityTableMapping[] getTableMappings() { @Override
public EntityTableMapping[] getTableMappings() {
return tableMappings; return tableMappings;
} }
public EntityTableMapping getTableMapping(int i) { protected EntityTableMapping getTableMapping(int i) {
return tableMappings[i]; return tableMappings[i];
} }
@ -2680,22 +2646,12 @@ public abstract class AbstractEntityPersister
* Unfortunately we cannot directly use `SelectableMapping#getContainingTableExpression()` * Unfortunately we cannot directly use `SelectableMapping#getContainingTableExpression()`
* as that blows up for attributes declared on super-type for union-subclass mappings * as that blows up for attributes declared on super-type for union-subclass mappings
*/ */
@Override
public String physicalTableNameForMutation(SelectableMapping selectableMapping) { public String physicalTableNameForMutation(SelectableMapping selectableMapping) {
assert !selectableMapping.isFormula(); assert !selectableMapping.isFormula();
return selectableMapping.getContainingTableExpression(); return selectableMapping.getContainingTableExpression();
} }
public EntityTableMapping getPhysicalTableMappingForMutation(SelectableMapping selectableMapping) {
final String tableNameForMutation = physicalTableNameForMutation( selectableMapping );
for ( int i = 0; i < tableMappings.length; i++ ) {
if ( tableNameForMutation.equals( tableMappings[i].getTableName() ) ) {
return tableMappings[i];
}
}
throw new IllegalArgumentException( "Unable to resolve TableMapping for selectable - " + selectableMapping );
}
@Override @Override
public EntityMappingType getTargetPart() { public EntityMappingType getTargetPart() {
return this; return this;
@ -2863,7 +2819,7 @@ public abstract class AbstractEntityPersister
joinedTableReference, joinedTableReference,
needsDiscriminator() needsDiscriminator()
? getRootTableKeyColumnNames() ? getRootTableKeyColumnNames()
: getKeyColumnNames(), : getIdentifierColumnNames(),
getSubclassTableKeyColumns( i ), getSubclassTableKeyColumns( i ),
creationState creationState
) )
@ -3256,8 +3212,6 @@ public abstract class AbstractEntityPersister
return GeneratedValuesHelper.getGeneratedValuesDelegate( this, UPDATE ); return GeneratedValuesHelper.getGeneratedValuesDelegate( this, UPDATE );
} }
public abstract String[][] getContraintOrderedTableKeyColumnClosure();
private static class TableMappingBuilder { private static class TableMappingBuilder {
private final String tableName; private final String tableName;
private final int relativePosition; private final int relativePosition;
@ -3496,9 +3450,11 @@ public abstract class AbstractEntityPersister
} }
} }
@Override
public void addDiscriminatorToInsertGroup(MutationGroupBuilder insertGroupBuilder) { public void addDiscriminatorToInsertGroup(MutationGroupBuilder insertGroupBuilder) {
} }
@Override
public void addSoftDeleteToInsertGroup(MutationGroupBuilder insertGroupBuilder) { public void addSoftDeleteToInsertGroup(MutationGroupBuilder insertGroupBuilder) {
if ( softDeleteMapping != null ) { if ( softDeleteMapping != null ) {
final TableInsertBuilder insertBuilder = insertGroupBuilder.getTableDetailsBuilder( getIdentifierTableName() ); final TableInsertBuilder insertBuilder = insertGroupBuilder.getTableDetailsBuilder( getIdentifierTableName() );
@ -3805,10 +3761,6 @@ public abstract class AbstractEntityPersister
return entityMetamodel.getName(); return entityMetamodel.getName();
} }
public boolean isPolymorphic() {
return entityMetamodel.isPolymorphic();
}
@Override @Override
public boolean isInherited() { public boolean isInherited() {
return entityMetamodel.isInherited(); return entityMetamodel.isInherited();
@ -4047,10 +3999,6 @@ public abstract class AbstractEntityPersister
return concreteTypeLoader.getConcreteType( id, session ); return concreteTypeLoader.getConcreteType( id, session );
} }
public String[] getKeyColumnNames() {
return getIdentifierColumnNames();
}
/** /**
* {@inheritDoc} * {@inheritDoc}
* *
@ -4169,6 +4117,7 @@ public abstract class AbstractEntityPersister
return entityMetamodel.getPropertyCheckability(); return entityMetamodel.getPropertyCheckability();
} }
@Override
public boolean[] getNonLazyPropertyUpdateability() { public boolean[] getNonLazyPropertyUpdateability() {
return entityMetamodel.getNonlazyPropertyUpdateability(); return entityMetamodel.getNonlazyPropertyUpdateability();
} }
@ -4418,6 +4367,7 @@ public abstract class AbstractEntityPersister
return this; return this;
} }
@Override
public boolean hasMultipleTables() { public boolean hasMultipleTables() {
return false; return false;
} }
@ -4638,7 +4588,12 @@ public abstract class AbstractEntityPersister
return entityMetamodel.getBytecodeEnhancementMetadata(); return entityMetamodel.getBytecodeEnhancementMetadata();
} }
public int determineTableNumberForColumn(String columnName) { @Override
public String getTableNameForColumn(String columnName) {
return getTableName( determineTableNumberForColumn( columnName ) );
}
protected int determineTableNumberForColumn(String columnName) {
return 0; return 0;
} }

View File

@ -12,7 +12,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.hibernate.FetchMode;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.Incubating; import org.hibernate.Incubating;
import org.hibernate.LockMode; import org.hibernate.LockMode;
@ -58,6 +57,8 @@ import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.sql.ast.spi.SqlAliasStemHelper; import org.hibernate.sql.ast.spi.SqlAliasStemHelper;
import org.hibernate.sql.ast.tree.from.RootTableGroupProducer; import org.hibernate.sql.ast.tree.from.RootTableGroupProducer;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.insert.InsertSelectStatement;
import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
@ -796,7 +797,11 @@ public interface EntityPersister extends EntityMappingType, EntityMutationTarget
* (is the property optimistic-locked) * (is the property optimistic-locked)
*/ */
boolean[] getPropertyVersionability(); boolean[] getPropertyVersionability();
boolean[] getPropertyLaziness(); boolean[] getPropertyLaziness();
boolean[] getNonLazyPropertyUpdateability();
/** /**
* Get the cascade styles of the properties (optional operation) * Get the cascade styles of the properties (optional operation)
*/ */
@ -1360,6 +1365,37 @@ public interface EntityPersister extends EntityMappingType, EntityMutationTarget
*/ */
String getDiscriminatorAlias(String suffix); String getDiscriminatorAlias(String suffix);
boolean hasMultipleTables();
String[] getTableNames();
/**
* @deprecated Only ever used from places where we really want to use<ul>
* <li>{@link SelectStatement} (select generator)</li>
* <li>{@link InsertSelectStatement}</li>
* <li>{@link org.hibernate.sql.ast.tree.update.UpdateStatement}</li>
* <li>{@link org.hibernate.sql.ast.tree.delete.DeleteStatement}</li>
* </ul>
*/
@Deprecated( since = "6.2" )
String getTableName(int j);
String[] getKeyColumns(int j);
int getTableSpan();
boolean isInverseTable(int j);
boolean isNullableTable(int j);
boolean hasDuplicateTables();
int getSubclassTableSpan();
String getSubclassTableName(int j);
String getTableNameForColumn(String columnName);
/** /**
* @return the column name for the discriminator as specified in the mapping. * @return the column name for the discriminator as specified in the mapping.
* *
@ -1378,20 +1414,14 @@ public interface EntityPersister extends EntityMappingType, EntityMutationTarget
*/ */
boolean hasRowId(); boolean hasRowId();
String[] getSubclassPropertyColumnNames(int i);
/** /**
* Return the column alias names used to persist/query the named property of the class or a subclass (optional operation). * Return the column alias names used to persist/query the named property of the class or a subclass (optional operation).
*/ */
String[] getSubclassPropertyColumnAliases(String propertyName, String suffix); String[] getSubclassPropertyColumnAliases(String propertyName, String suffix);
/** int countSubclassProperties();
* May this (subclass closure) property be fetched using an SQL outer join?
*/
FetchMode getFetchMode(int i);
/**
* Get the type of the numbered property of the class or a subclass.
*/
Type getSubclassPropertyType(int i);
/** /**
* Get the column names for the given property path * Get the column names for the given property path
@ -1413,6 +1443,13 @@ public interface EntityPersister extends EntityMappingType, EntityMutationTarget
/** /**
* Given a property path, return the corresponding column name(s). * Given a property path, return the corresponding column name(s).
*
* @deprecated No longer used in ORM core
*/ */
@Deprecated(since = "7.0", forRemoval = true)
String[] toColumns(String propertyName); String[] toColumns(String propertyName);
boolean isSharedColumn(String columnExpression);
String[][] getConstraintOrderedTableKeyColumnClosure();
} }

View File

@ -960,12 +960,12 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
} }
@Override @Override
public String[][] getContraintOrderedTableKeyColumnClosure() { public String[][] getConstraintOrderedTableKeyColumnClosure() {
return constraintOrderedKeyColumnNames; return constraintOrderedKeyColumnNames;
} }
@Override @Override
public int determineTableNumberForColumn(String columnName) { protected int determineTableNumberForColumn(String columnName) {
// HHH-7630: In case the naturalOrder/identifier column is explicitly given in the ordering, check here. // HHH-7630: In case the naturalOrder/identifier column is explicitly given in the ordering, check here.
for ( int i = 0, max = naturalOrderTableKeyColumns.length; i < max; i++ ) { for ( int i = 0, max = naturalOrderTableKeyColumns.length; i < max; i++ ) {
final String[] keyColumns = naturalOrderTableKeyColumns[i]; final String[] keyColumns = naturalOrderTableKeyColumns[i];

View File

@ -559,7 +559,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
} }
@Override @Override
public String[][] getContraintOrderedTableKeyColumnClosure() { public String[][] getConstraintOrderedTableKeyColumnClosure() {
return constraintOrderedKeyColumnNames; return constraintOrderedKeyColumnNames;
} }

View File

@ -514,9 +514,9 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
subMappingTypesAndThis.add( this ); subMappingTypesAndThis.add( this );
subMappingTypesAndThis.addAll( subMappingTypes ); subMappingTypesAndThis.addAll( subMappingTypes );
for ( EntityMappingType mappingType : subMappingTypesAndThis ) { for ( EntityMappingType mappingType : subMappingTypesAndThis ) {
final AbstractEntityPersister persister = (AbstractEntityPersister) mappingType; final EntityPersister persister = (EntityPersister) mappingType;
final String subclassTableName; final String subclassTableName;
if ( persister.hasSubclasses() ) { if ( mappingType.hasSubclasses() ) {
subclassTableName = persister.getRootTableName(); subclassTableName = persister.getRootTableName();
} }
else { else {
@ -624,7 +624,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
} }
@Override @Override
public String[][] getContraintOrderedTableKeyColumnClosure() { public String[][] getConstraintOrderedTableKeyColumnClosure() {
return constraintOrderedKeyColumnNames; return constraintOrderedKeyColumnNames;
} }

View File

@ -17,9 +17,8 @@ import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.EntityRowIdMapping;
import org.hibernate.metamodel.mapping.EntityVersionMapping; import org.hibernate.metamodel.mapping.EntityVersionMapping;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.sql.model.MutationOperation; import org.hibernate.sql.model.MutationOperation;
import org.hibernate.sql.model.MutationOperationGroup; import org.hibernate.sql.model.MutationOperationGroup;
@ -40,7 +39,7 @@ public abstract class AbstractDeleteCoordinator
private MutationOperationGroup noVersionDeleteGroup; private MutationOperationGroup noVersionDeleteGroup;
public AbstractDeleteCoordinator( public AbstractDeleteCoordinator(
AbstractEntityPersister entityPersister, EntityPersister entityPersister,
SessionFactoryImplementor factory) { SessionFactoryImplementor factory) {
super( entityPersister, factory ); super( entityPersister, factory );
@ -169,7 +168,7 @@ public abstract class AbstractDeleteCoordinator
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
JdbcValueBindings jdbcValueBindings) { JdbcValueBindings jdbcValueBindings) {
if ( loadedState != null ) { if ( loadedState != null ) {
final AbstractEntityPersister persister = entityPersister(); final EntityPersister persister = entityPersister();
final boolean[] versionability = persister.getPropertyVersionability(); final boolean[] versionability = persister.getPropertyVersionability();
for ( int attributeIndex = 0; attributeIndex < versionability.length; attributeIndex++ ) { for ( int attributeIndex = 0; attributeIndex < versionability.length; attributeIndex++ ) {
final AttributeMapping attribute; final AttributeMapping attribute;
@ -206,7 +205,7 @@ public abstract class AbstractDeleteCoordinator
private void applyVersionLocking( private void applyVersionLocking(
Object version, Object version,
JdbcValueBindings jdbcValueBindings) { JdbcValueBindings jdbcValueBindings) {
final AbstractEntityPersister persister = entityPersister(); final EntityPersister persister = entityPersister();
final EntityVersionMapping versionMapping = persister.getVersionMapping(); final EntityVersionMapping versionMapping = persister.getVersionMapping();
if ( version != null && versionMapping != null ) { if ( version != null && versionMapping != null ) {
jdbcValueBindings.bindValue( jdbcValueBindings.bindValue(
@ -225,7 +224,7 @@ public abstract class AbstractDeleteCoordinator
MutationOperationGroup operationGroup, MutationOperationGroup operationGroup,
SharedSessionContractImplementor session) { SharedSessionContractImplementor session) {
final JdbcValueBindings jdbcValueBindings = mutationExecutor.getJdbcValueBindings(); final JdbcValueBindings jdbcValueBindings = mutationExecutor.getJdbcValueBindings();
final EntityRowIdMapping rowIdMapping = entityPersister().getRowIdMapping(); // final EntityRowIdMapping rowIdMapping = entityPersister().getRowIdMapping();
for ( int position = 0; position < operationGroup.getNumberOfOperations(); position++ ) { for ( int position = 0; position < operationGroup.getNumberOfOperations(); position++ ) {
final MutationOperation jdbcMutation = operationGroup.getOperation( position ); final MutationOperation jdbcMutation = operationGroup.getOperation( position );

View File

@ -19,7 +19,7 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.generator.OnExecutionGenerator; import org.hibernate.generator.OnExecutionGenerator;
import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.AttributeMappingsList; import org.hibernate.metamodel.mapping.AttributeMappingsList;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.sql.model.ModelMutationLogging; import org.hibernate.sql.model.ModelMutationLogging;
import org.hibernate.sql.model.MutationOperation; import org.hibernate.sql.model.MutationOperation;
import org.hibernate.sql.model.MutationOperationGroup; import org.hibernate.sql.model.MutationOperationGroup;
@ -34,25 +34,26 @@ import org.hibernate.sql.model.internal.MutationOperationGroupFactory;
/** /**
* Base support for coordinating mutations against an entity * Base support for coordinating mutations against an entity
* *
* @implNote Split simply to help minimize the size of {@link AbstractEntityPersister} * @implNote Split simply to help minimize the size of
* {@link org.hibernate.persister.entity.AbstractEntityPersister}
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@Internal @Internal
public abstract class AbstractMutationCoordinator { public abstract class AbstractMutationCoordinator {
protected final AbstractEntityPersister entityPersister; protected final EntityPersister entityPersister;
protected final SessionFactoryImplementor factory; protected final SessionFactoryImplementor factory;
protected final MutationExecutorService mutationExecutorService; protected final MutationExecutorService mutationExecutorService;
protected final Dialect dialect; protected final Dialect dialect;
public AbstractMutationCoordinator(AbstractEntityPersister entityPersister, SessionFactoryImplementor factory) { public AbstractMutationCoordinator(EntityPersister entityPersister, SessionFactoryImplementor factory) {
this.entityPersister = entityPersister; this.entityPersister = entityPersister;
this.factory = factory; this.factory = factory;
dialect = factory.getJdbcServices().getDialect(); dialect = factory.getJdbcServices().getDialect();
this.mutationExecutorService = factory.getServiceRegistry().getService( MutationExecutorService.class ); this.mutationExecutorService = factory.getServiceRegistry().getService( MutationExecutorService.class );
} }
protected AbstractEntityPersister entityPersister() { protected EntityPersister entityPersister() {
return entityPersister; return entityPersister;
} }
@ -140,7 +141,7 @@ public abstract class AbstractMutationCoordinator {
Object[] loadedState, Object[] loadedState,
SharedSessionContractImplementor session, SharedSessionContractImplementor session,
JdbcValueBindings jdbcValueBindings) { JdbcValueBindings jdbcValueBindings) {
final AbstractEntityPersister persister = entityPersister(); final EntityPersister persister = entityPersister();
if ( persister.hasPartitionedSelectionMapping() ) { if ( persister.hasPartitionedSelectionMapping() ) {
final AttributeMappingsList attributeMappings = persister.getAttributeMappings(); final AttributeMappingsList attributeMappings = persister.getAttributeMappings();
final int size = attributeMappings.size(); final int size = attributeMappings.size();
@ -168,13 +169,13 @@ public abstract class AbstractMutationCoordinator {
} }
} }
protected static boolean needsRowId(AbstractEntityPersister entityPersister, EntityTableMapping tableMapping) { protected static boolean needsRowId(EntityPersister entityPersister, EntityTableMapping tableMapping) {
return entityPersister.getRowIdMapping() != null && tableMapping.isIdentifierTable(); return entityPersister.getRowIdMapping() != null && tableMapping.isIdentifierTable();
} }
protected static void applyKeyRestriction( protected static void applyKeyRestriction(
Object rowId, Object rowId,
AbstractEntityPersister entityPersister, EntityPersister entityPersister,
RestrictedTableMutationBuilder<?, ?> tableMutationBuilder, RestrictedTableMutationBuilder<?, ?> tableMutationBuilder,
EntityTableMapping tableMapping) { EntityTableMapping tableMapping) {
if ( rowId != null && needsRowId( entityPersister, tableMapping ) ) { if ( rowId != null && needsRowId( entityPersister, tableMapping ) ) {

View File

@ -13,7 +13,7 @@ import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.AttributeMappingsList; import org.hibernate.metamodel.mapping.AttributeMappingsList;
import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.SelectableMapping;
import org.hibernate.metamodel.mapping.SoftDeleteMapping; import org.hibernate.metamodel.mapping.SoftDeleteMapping;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.sql.model.MutationOperation; import org.hibernate.sql.model.MutationOperation;
import org.hibernate.sql.model.MutationOperationGroup; import org.hibernate.sql.model.MutationOperationGroup;
import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.MutationType;
@ -30,7 +30,7 @@ import org.hibernate.sql.model.internal.MutationOperationGroupFactory;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class DeleteCoordinatorSoft extends AbstractDeleteCoordinator { public class DeleteCoordinatorSoft extends AbstractDeleteCoordinator {
public DeleteCoordinatorSoft(AbstractEntityPersister entityPersister, SessionFactoryImplementor factory) { public DeleteCoordinatorSoft(EntityPersister entityPersister, SessionFactoryImplementor factory) {
super( entityPersister, factory ); super( entityPersister, factory );
} }
@ -64,7 +64,7 @@ public class DeleteCoordinatorSoft extends AbstractDeleteCoordinator {
} }
private void applyPartitionKeyRestriction(TableUpdateBuilder<?> tableUpdateBuilder) { private void applyPartitionKeyRestriction(TableUpdateBuilder<?> tableUpdateBuilder) {
final AbstractEntityPersister persister = entityPersister(); final EntityPersister persister = entityPersister();
if ( persister.hasPartitionedSelectionMapping() ) { if ( persister.hasPartitionedSelectionMapping() ) {
final AttributeMappingsList attributeMappings = persister.getAttributeMappings(); final AttributeMappingsList attributeMappings = persister.getAttributeMappings();
for ( int m = 0; m < attributeMappings.size(); m++ ) { for ( int m = 0; m < attributeMappings.size(); m++ ) {
@ -125,7 +125,7 @@ public class DeleteCoordinatorSoft extends AbstractDeleteCoordinator {
TableUpdateBuilderStandard<MutationOperation> tableUpdateBuilder, TableUpdateBuilderStandard<MutationOperation> tableUpdateBuilder,
Object[] loadedState, Object[] loadedState,
SharedSessionContractImplementor session) { SharedSessionContractImplementor session) {
final AbstractEntityPersister persister = entityPersister(); final EntityPersister persister = entityPersister();
assert loadedState != null; assert loadedState != null;
assert lockStyle.isAllOrDirty(); assert lockStyle.isAllOrDirty();
assert persister.optimisticLockStyle().isAllOrDirty(); assert persister.optimisticLockStyle().isAllOrDirty();

View File

@ -12,7 +12,7 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.AttributeMappingsList; import org.hibernate.metamodel.mapping.AttributeMappingsList;
import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.SelectableMapping;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.sql.model.MutationOperationGroup; import org.hibernate.sql.model.MutationOperationGroup;
import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.MutationType;
import org.hibernate.sql.model.ast.ColumnValueBindingList; import org.hibernate.sql.model.ast.ColumnValueBindingList;
@ -29,7 +29,7 @@ import org.hibernate.sql.model.ast.builder.TableDeleteBuilderStandard;
*/ */
public class DeleteCoordinatorStandard extends AbstractDeleteCoordinator { public class DeleteCoordinatorStandard extends AbstractDeleteCoordinator {
public DeleteCoordinatorStandard(AbstractEntityPersister entityPersister, SessionFactoryImplementor factory) { public DeleteCoordinatorStandard(EntityPersister entityPersister, SessionFactoryImplementor factory) {
super( entityPersister, factory ); super( entityPersister, factory );
} }
@ -69,7 +69,7 @@ public class DeleteCoordinatorStandard extends AbstractDeleteCoordinator {
if ( applyVersion ) { if ( applyVersion ) {
// apply any optimistic locking // apply any optimistic locking
applyOptimisticLocking( deleteGroupBuilder, loadedState, session ); applyOptimisticLocking( deleteGroupBuilder, loadedState, session );
final AbstractEntityPersister persister = entityPersister(); final EntityPersister persister = entityPersister();
if ( persister.hasPartitionedSelectionMapping() ) { if ( persister.hasPartitionedSelectionMapping() ) {
final AttributeMappingsList attributeMappings = persister.getAttributeMappings(); final AttributeMappingsList attributeMappings = persister.getAttributeMappings();
for ( int m = 0; m < attributeMappings.size(); m++ ) { for ( int m = 0; m < attributeMappings.size(); m++ ) {
@ -122,7 +122,7 @@ public class DeleteCoordinatorStandard extends AbstractDeleteCoordinator {
MutationGroupBuilder mutationGroupBuilder, MutationGroupBuilder mutationGroupBuilder,
Object[] loadedState, Object[] loadedState,
SharedSessionContractImplementor session) { SharedSessionContractImplementor session) {
final AbstractEntityPersister persister = entityPersister(); final EntityPersister persister = entityPersister();
assert loadedState != null; assert loadedState != null;
assert lockStyle.isAllOrDirty(); assert lockStyle.isAllOrDirty();
assert persister.optimisticLockStyle().isAllOrDirty(); assert persister.optimisticLockStyle().isAllOrDirty();

View File

@ -7,14 +7,17 @@
package org.hibernate.persister.entity.mutation; package org.hibernate.persister.entity.mutation;
import org.hibernate.Incubating; import org.hibernate.Incubating;
import org.hibernate.Internal;
import org.hibernate.annotations.Table; import org.hibernate.annotations.Table;
import org.hibernate.engine.jdbc.mutation.MutationExecutor; import org.hibernate.engine.jdbc.mutation.MutationExecutor;
import org.hibernate.generator.values.GeneratedValuesMutationDelegate; import org.hibernate.generator.values.GeneratedValuesMutationDelegate;
import org.hibernate.id.insert.InsertGeneratedIdentifierDelegate; import org.hibernate.id.insert.InsertGeneratedIdentifierDelegate;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.SelectableMapping;
import org.hibernate.sql.model.MutationTarget; import org.hibernate.sql.model.MutationTarget;
import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.MutationType;
import org.hibernate.sql.model.ast.builder.MutationGroupBuilder;
/** /**
* Anything that can be the target of {@linkplain MutationExecutor mutations} * Anything that can be the target of {@linkplain MutationExecutor mutations}
@ -30,11 +33,26 @@ public interface EntityMutationTarget extends MutationTarget<EntityTableMapping>
@Override @Override
EntityTableMapping getIdentifierTableMapping(); EntityTableMapping getIdentifierTableMapping();
@Internal
EntityTableMapping[] getTableMappings();
/** /**
* The ModelPart describing the identifier/key for this target * The ModelPart describing the identifier/key for this target
*/ */
ModelPart getIdentifierDescriptor(); ModelPart getIdentifierDescriptor();
String physicalTableNameForMutation(SelectableMapping selectableMapping);
void addDiscriminatorToInsertGroup(MutationGroupBuilder insertGroupBuilder);
void addSoftDeleteToInsertGroup(MutationGroupBuilder insertGroupBuilder);
/**
* The name of the table to use when performing mutations (INSERT,UPDATE,DELETE)
* for the given attribute
*/
String getAttributeMutationTableName(int i);
/** /**
* Whether this target defines any potentially skippable tables. * Whether this target defines any potentially skippable tables.
* <p> * <p>
@ -43,7 +61,10 @@ public interface EntityMutationTarget extends MutationTarget<EntityTableMapping>
* *
* @see Table#inverse * @see Table#inverse
* @see Table#optional * @see Table#optional
*
* @deprecated No longer called
*/ */
@Deprecated(since = "7.0", forRemoval = true)
boolean hasSkippableTables(); boolean hasSkippableTables();
/** /**

View File

@ -28,7 +28,7 @@ import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.AttributeMappingsList; import org.hibernate.metamodel.mapping.AttributeMappingsList;
import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping; import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping;
import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.sql.model.MutationOperation; import org.hibernate.sql.model.MutationOperation;
import org.hibernate.sql.model.MutationOperationGroup; import org.hibernate.sql.model.MutationOperationGroup;
import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.MutationType;
@ -56,7 +56,7 @@ public class InsertCoordinatorStandard extends AbstractMutationCoordinator imple
private final MutationOperationGroup staticInsertGroup; private final MutationOperationGroup staticInsertGroup;
private final BasicBatchKey batchKey; private final BasicBatchKey batchKey;
public InsertCoordinatorStandard(AbstractEntityPersister entityPersister, SessionFactoryImplementor factory) { public InsertCoordinatorStandard(EntityPersister entityPersister, SessionFactoryImplementor factory) {
super( entityPersister, factory ); super( entityPersister, factory );
if ( entityPersister.isIdentifierAssignedByInsert() || entityPersister.hasInsertGeneratedProperties() ) { if ( entityPersister.isIdentifierAssignedByInsert() || entityPersister.hasInsertGeneratedProperties() ) {
@ -131,7 +131,7 @@ public class InsertCoordinatorStandard extends AbstractMutationCoordinator imple
} }
protected boolean preInsertInMemoryValueGeneration(Object[] values, Object entity, SharedSessionContractImplementor session) { protected boolean preInsertInMemoryValueGeneration(Object[] values, Object entity, SharedSessionContractImplementor session) {
final AbstractEntityPersister persister = entityPersister(); final EntityPersister persister = entityPersister();
final EntityMetamodel entityMetamodel = persister.getEntityMetamodel(); final EntityMetamodel entityMetamodel = persister.getEntityMetamodel();
boolean foundStateDependentGenerator = false; boolean foundStateDependentGenerator = false;
if ( entityMetamodel.hasPreInsertGeneratedValues() ) { if ( entityMetamodel.hasPreInsertGeneratedValues() ) {

View File

@ -7,7 +7,7 @@
package org.hibernate.persister.entity.mutation; package org.hibernate.persister.entity.mutation;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.sql.model.MutationOperation; import org.hibernate.sql.model.MutationOperation;
import org.hibernate.sql.model.ast.builder.AbstractTableUpdateBuilder; import org.hibernate.sql.model.ast.builder.AbstractTableUpdateBuilder;
import org.hibernate.sql.model.ast.builder.TableMergeBuilder; import org.hibernate.sql.model.ast.builder.TableMergeBuilder;
@ -19,7 +19,7 @@ import org.hibernate.sql.model.ast.builder.TableMergeBuilder;
*/ */
public class MergeCoordinator extends UpdateCoordinatorStandard { public class MergeCoordinator extends UpdateCoordinatorStandard {
public MergeCoordinator(AbstractEntityPersister entityPersister, SessionFactoryImplementor factory) { public MergeCoordinator(EntityPersister entityPersister, SessionFactoryImplementor factory) {
super(entityPersister, factory); super(entityPersister, factory);
} }

View File

@ -7,9 +7,9 @@
package org.hibernate.persister.entity.mutation; package org.hibernate.persister.entity.mutation;
import org.hibernate.generator.values.GeneratedValues; import org.hibernate.generator.values.GeneratedValues;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.sql.model.internal.MutationOperationGroupFactory; import org.hibernate.sql.model.internal.MutationOperationGroupFactory;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.sql.model.MutationOperationGroup; import org.hibernate.sql.model.MutationOperationGroup;
import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.MutationType;
@ -19,7 +19,7 @@ import org.hibernate.sql.model.MutationType;
public class UpdateCoordinatorNoOp implements UpdateCoordinator { public class UpdateCoordinatorNoOp implements UpdateCoordinator {
private final MutationOperationGroup operationGroup; private final MutationOperationGroup operationGroup;
public UpdateCoordinatorNoOp(AbstractEntityPersister entityPersister) { public UpdateCoordinatorNoOp(EntityPersister entityPersister) {
operationGroup = MutationOperationGroupFactory.noOperations( MutationType.UPDATE, entityPersister ); operationGroup = MutationOperationGroupFactory.noOperations( MutationType.UPDATE, entityPersister );
} }

View File

@ -40,7 +40,6 @@ import org.hibernate.metamodel.mapping.AttributeMappingsList;
import org.hibernate.metamodel.mapping.EntityVersionMapping; import org.hibernate.metamodel.mapping.EntityVersionMapping;
import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.SelectableMapping;
import org.hibernate.metamodel.mapping.SingularAttributeMapping; import org.hibernate.metamodel.mapping.SingularAttributeMapping;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.sql.model.MutationOperation; import org.hibernate.sql.model.MutationOperation;
import org.hibernate.sql.model.MutationOperationGroup; import org.hibernate.sql.model.MutationOperationGroup;
@ -73,11 +72,7 @@ import static org.hibernate.internal.util.collections.ArrayHelper.trim;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class UpdateCoordinatorStandard extends AbstractMutationCoordinator implements UpdateCoordinator { public class UpdateCoordinatorStandard extends AbstractMutationCoordinator implements UpdateCoordinator {
// `org.hibernate.orm.test.mapping.onetoone.OneToOneMapsIdChangeParentTest#test` expects private static final CoreMessageLogger LOG = CoreLogging.messageLogger( UpdateCoordinatorStandard.class );
// the logger-name to be AbstractEntityPersister
// todo (mutation) : Change this? It is an interesting "api" question wrt logging
// private static final CoreMessageLogger LOG = CoreLogging.messageLogger( UpdateCoordinatorStandard.class );
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( AbstractEntityPersister.class );
private final MutationOperationGroup staticUpdateGroup; private final MutationOperationGroup staticUpdateGroup;
private final BatchKey batchKey; private final BatchKey batchKey;
@ -85,7 +80,7 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
private final MutationOperationGroup versionUpdateGroup; private final MutationOperationGroup versionUpdateGroup;
private final BatchKey versionUpdateBatchkey; private final BatchKey versionUpdateBatchkey;
public UpdateCoordinatorStandard(AbstractEntityPersister entityPersister, SessionFactoryImplementor factory) { public UpdateCoordinatorStandard(EntityPersister entityPersister, SessionFactoryImplementor factory) {
super( entityPersister, factory ); super( entityPersister, factory );
// NOTE : even given dynamic-update and/or dirty optimistic locking // NOTE : even given dynamic-update and/or dirty optimistic locking
@ -105,7 +100,7 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
//Used by Hibernate Reactive to efficiently create new instances of this same class //Used by Hibernate Reactive to efficiently create new instances of this same class
protected UpdateCoordinatorStandard( protected UpdateCoordinatorStandard(
AbstractEntityPersister entityPersister, EntityPersister entityPersister,
SessionFactoryImplementor factory, SessionFactoryImplementor factory,
MutationOperationGroup staticUpdateGroup, MutationOperationGroup staticUpdateGroup,
BatchKey batchKey, BatchKey batchKey,
@ -216,7 +211,7 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
} }
else if ( dirtyAttributeIndexes != null else if ( dirtyAttributeIndexes != null
&& entityPersister().hasUninitializedLazyProperties( entity ) && entityPersister().hasUninitializedLazyProperties( entity )
&& entityPersister().hasLazyDirtyFields( dirtyAttributeIndexes ) ) { && hasLazyDirtyFields( entityPersister(), dirtyAttributeIndexes ) ) {
// we have an entity with dirty lazy attributes. we need to use dynamic // we have an entity with dirty lazy attributes. we need to use dynamic
// delete and add the dirty, lazy attributes plus the non-lazy attributes // delete and add the dirty, lazy attributes plus the non-lazy attributes
forceDynamicUpdate = true; forceDynamicUpdate = true;
@ -615,7 +610,7 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
Object rowId, Object rowId,
boolean forceDynamicUpdate, boolean forceDynamicUpdate,
SharedSessionContractImplementor session) { SharedSessionContractImplementor session) {
final AbstractEntityPersister persister = entityPersister(); final EntityPersister persister = entityPersister();
final AttributeMappingsList attributeMappings = persister.getAttributeMappings(); final AttributeMappingsList attributeMappings = persister.getAttributeMappings();
// NOTE: // NOTE:
@ -719,7 +714,7 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
private void processSet(UpdateValuesAnalysisImpl analysis, SelectableMapping selectable, boolean needsDynamicUpdate) { private void processSet(UpdateValuesAnalysisImpl analysis, SelectableMapping selectable, boolean needsDynamicUpdate) {
if ( selectable != null && !selectable.isFormula() && selectable.isUpdateable() ) { if ( selectable != null && !selectable.isFormula() && selectable.isUpdateable() ) {
final EntityTableMapping tableMapping = entityPersister().getPhysicalTableMappingForMutation( selectable ); final EntityTableMapping tableMapping = physicalTableMappingForMutation( entityPersister(), selectable );
analysis.registerColumnSet( tableMapping, selectable.getSelectionExpression(), selectable.getWriteExpression() ); analysis.registerColumnSet( tableMapping, selectable.getSelectionExpression(), selectable.getWriteExpression() );
if ( needsDynamicUpdate ) { if ( needsDynamicUpdate ) {
analysis.getTablesNeedingDynamicUpdate().add( tableMapping ); analysis.getTablesNeedingDynamicUpdate().add( tableMapping );
@ -739,7 +734,7 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
null, null,
(valueIndex, updateAnalysis, noop, jdbcValue, columnMapping) -> { (valueIndex, updateAnalysis, noop, jdbcValue, columnMapping) -> {
if ( !columnMapping.isFormula() ) { if ( !columnMapping.isFormula() ) {
final EntityTableMapping tableMapping = entityPersister().getPhysicalTableMappingForMutation( columnMapping ); final EntityTableMapping tableMapping = physicalTableMappingForMutation( entityPersister(), columnMapping );
updateAnalysis.registerColumnOptLock( tableMapping, columnMapping.getSelectionExpression(), jdbcValue ); updateAnalysis.registerColumnOptLock( tableMapping, columnMapping.getSelectionExpression(), jdbcValue );
} }
}, },
@ -1151,7 +1146,7 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
} }
private void applyPartitionKeyRestriction(TableUpdateBuilder<?> tableUpdateBuilder) { private void applyPartitionKeyRestriction(TableUpdateBuilder<?> tableUpdateBuilder) {
final AbstractEntityPersister persister = entityPersister(); final EntityPersister persister = entityPersister();
if ( persister.hasPartitionedSelectionMapping() ) { if ( persister.hasPartitionedSelectionMapping() ) {
final AttributeMappingsList attributeMappings = persister.getAttributeMappings(); final AttributeMappingsList attributeMappings = persister.getAttributeMappings();
for ( int m = 0; m < attributeMappings.size(); m++ ) { for ( int m = 0; m < attributeMappings.size(); m++ ) {
@ -1698,6 +1693,29 @@ public class UpdateCoordinatorStandard extends AbstractMutationCoordinator imple
AttributeAnalysis.DirtynessStatus isDirty(int position, AttributeMapping attribute); AttributeAnalysis.DirtynessStatus isDirty(int position, AttributeMapping attribute);
} }
public boolean hasLazyDirtyFields(EntityPersister persister, int[] dirtyFields) {
final boolean[] propertyLaziness = persister.getPropertyLaziness();
for ( int i = 0; i < dirtyFields.length; i++ ) {
if ( propertyLaziness[dirtyFields[i]] ) {
return true;
}
}
return false;
}
public EntityTableMapping physicalTableMappingForMutation(
EntityPersister persister, SelectableMapping selectableMapping) {
final String tableNameForMutation = persister.physicalTableNameForMutation( selectableMapping );
final EntityTableMapping[] tableMappings = persister.getTableMappings();
for ( int i = 0; i < tableMappings.length; i++ ) {
if ( tableNameForMutation.equals( tableMappings[i].getTableName() ) ) {
return tableMappings[i];
}
}
throw new IllegalArgumentException( "Unable to resolve TableMapping for selectable - " + selectableMapping );
}
@Override @Override
public String toString() { public String toString() {
return "UpdateCoordinatorStandard(" + entityPersister().getEntityName() + ")"; return "UpdateCoordinatorStandard(" + entityPersister().getEntityName() + ")";

View File

@ -85,8 +85,8 @@ public class AnonymousTupleEntityValuedModelPart
private final DomainType<?> domainType; private final DomainType<?> domainType;
private final String componentName; private final String componentName;
private final EntityValuedModelPart delegate; private final EntityValuedModelPart delegate;
private final Set<String> targetKeyPropertyNames; // private final Set<String> targetKeyPropertyNames;
private final int fetchableIndex; // private final int fetchableIndex;
public AnonymousTupleEntityValuedModelPart( public AnonymousTupleEntityValuedModelPart(
EntityIdentifierMapping identifierMapping, EntityIdentifierMapping identifierMapping,
@ -108,8 +108,8 @@ public class AnonymousTupleEntityValuedModelPart
persister.getIdentifierType(), persister.getIdentifierType(),
persister.getFactory() persister.getFactory()
); );
this.targetKeyPropertyNames = targetKeyPropertyNames; // this.targetKeyPropertyNames = targetKeyPropertyNames;
this.fetchableIndex = fetchableIndex; // this.fetchableIndex = fetchableIndex;
} }
public ModelPart getForeignKeyPart() { public ModelPart getForeignKeyPart() {
@ -380,7 +380,7 @@ public class AnonymousTupleEntityValuedModelPart
} }
); );
} }
Consumer<TableGroup> tableGroupInitializerCallback = tg -> { return tg -> {
this.identifierMapping.forEachSelectable( this.identifierMapping.forEachSelectable(
(i, selectableMapping) -> { (i, selectableMapping) -> {
final SelectableMapping targetMapping = targetMappings.get( i ); final SelectableMapping targetMapping = targetMappings.get( i );
@ -401,7 +401,6 @@ public class AnonymousTupleEntityValuedModelPart
} }
); );
}; };
return tableGroupInitializerCallback;
} }
public TableGroup createTableGroupInternal( public TableGroup createTableGroupInternal(
@ -487,7 +486,8 @@ public class AnonymousTupleEntityValuedModelPart
public boolean canUseParentTableGroup(TableGroupProducer producer, NavigablePath navigablePath, ValuedModelPart valuedModelPart) { public boolean canUseParentTableGroup(TableGroupProducer producer, NavigablePath navigablePath, ValuedModelPart valuedModelPart) {
final ModelPart foreignKeyPart = getForeignKeyPart(); final ModelPart foreignKeyPart = getForeignKeyPart();
if ( foreignKeyPart instanceof AnonymousTupleNonAggregatedEntityIdentifierMapping ) { if ( foreignKeyPart instanceof AnonymousTupleNonAggregatedEntityIdentifierMapping ) {
final AnonymousTupleNonAggregatedEntityIdentifierMapping identifierMapping = (AnonymousTupleNonAggregatedEntityIdentifierMapping) foreignKeyPart; final AnonymousTupleNonAggregatedEntityIdentifierMapping identifierMapping =
(AnonymousTupleNonAggregatedEntityIdentifierMapping) foreignKeyPart;
final int numberOfFetchables = identifierMapping.getNumberOfFetchables(); final int numberOfFetchables = identifierMapping.getNumberOfFetchables();
for ( int i = 0; i< numberOfFetchables; i++ ) { for ( int i = 0; i< numberOfFetchables; i++ ) {
if ( valuedModelPart == identifierMapping.getFetchable( i ) ) { if ( valuedModelPart == identifierMapping.getFetchable( i ) ) {
@ -723,8 +723,7 @@ public class AnonymousTupleEntityValuedModelPart
@Override @Override
public boolean isSimpleJoinPredicate(Predicate predicate) { public boolean isSimpleJoinPredicate(Predicate predicate) {
return delegate instanceof TableGroupJoinProducer return delegate instanceof TableGroupJoinProducer
? ( (TableGroupJoinProducer) delegate ).isSimpleJoinPredicate( predicate ) && ( (TableGroupJoinProducer) delegate ).isSimpleJoinPredicate(predicate);
: false;
} }
@Override @Override

View File

@ -24,7 +24,6 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.loader.NonUniqueDiscoveredSqlAliasException; import org.hibernate.loader.NonUniqueDiscoveredSqlAliasException;
import org.hibernate.metamodel.mapping.BasicValuedMapping; import org.hibernate.metamodel.mapping.BasicValuedMapping;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.named.NamedResultSetMappingMemento; import org.hibernate.query.named.NamedResultSetMappingMemento;
import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy; import org.hibernate.query.results.dynamic.DynamicFetchBuilderLegacy;
@ -256,17 +255,16 @@ public class ResultSetMappingImpl implements ResultSetMapping {
if ( polymorphic && ( legacyFetchBuilders == null || legacyFetchBuilders.isEmpty() ) if ( polymorphic && ( legacyFetchBuilders == null || legacyFetchBuilders.isEmpty() )
&& !entityResult.hasJoinFetches() ) { && !entityResult.hasJoinFetches() ) {
final Set<String> aliases = new TreeSet<>( String.CASE_INSENSITIVE_ORDER ); final Set<String> aliases = new TreeSet<>( String.CASE_INSENSITIVE_ORDER );
final AbstractEntityPersister entityPersister = (AbstractEntityPersister) persister; for ( String[] columns : persister.getConstraintOrderedTableKeyColumnClosure() ) {
for ( String[] columns : entityPersister.getContraintOrderedTableKeyColumnClosure() ) {
addColumns( aliases, knownDuplicateAliases, columns ); addColumns( aliases, knownDuplicateAliases, columns );
} }
addColumn( aliases, knownDuplicateAliases, entityPersister.getDiscriminatorColumnName() ); addColumn( aliases, knownDuplicateAliases, persister.getDiscriminatorColumnName() );
addColumn( aliases, knownDuplicateAliases, entityPersister.getVersionColumnName() ); addColumn( aliases, knownDuplicateAliases, persister.getVersionColumnName() );
for ( int i = 0; i < entityPersister.countSubclassProperties(); i++ ) { for (int i = 0; i < persister.countSubclassProperties(); i++ ) {
addColumns( addColumns(
aliases, aliases,
knownDuplicateAliases, knownDuplicateAliases,
entityPersister.getSubclassPropertyColumnNames( i ) persister.getSubclassPropertyColumnNames( i )
); );
} }
} }

View File

@ -40,7 +40,6 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping; import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
import org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping; import org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping;
import org.hibernate.metamodel.model.domain.EntityDomainType; import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.BindableType; import org.hibernate.query.BindableType;
import org.hibernate.query.IllegalQueryOperationException; import org.hibernate.query.IllegalQueryOperationException;
@ -611,7 +610,7 @@ public class QuerySqmImpl<R>
final SqmInsertStatement<R> sqmInsert = (SqmInsertStatement<R>) getSqmStatement(); final SqmInsertStatement<R> sqmInsert = (SqmInsertStatement<R>) getSqmStatement();
final String entityNameToInsert = sqmInsert.getTarget().getModel().getHibernateEntityName(); final String entityNameToInsert = sqmInsert.getTarget().getModel().getHibernateEntityName();
final AbstractEntityPersister persister = (AbstractEntityPersister) final EntityPersister persister =
getSessionFactory().getMappingMetamodel().getEntityDescriptor( entityNameToInsert ); getSessionFactory().getMappingMetamodel().getEntityDescriptor( entityNameToInsert );
boolean useMultiTableInsert = persister.hasMultipleTables(); boolean useMultiTableInsert = persister.hasMultipleTables();

View File

@ -29,7 +29,6 @@ import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.MappingModelExpressible; import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.metamodel.mapping.SqlExpressible; import org.hibernate.metamodel.mapping.SqlExpressible;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.SemanticException; import org.hibernate.query.SemanticException;
import org.hibernate.query.SortDirection; import org.hibernate.query.SortDirection;
@ -144,14 +143,8 @@ public class CteInsertHandler implements InsertHandler {
this.domainParameterXref = domainParameterXref; this.domainParameterXref = domainParameterXref;
} }
public static CteTable createCteTable( public static CteTable createCteTable(CteTable sqmCteTable, List<CteColumn> sqmCteColumns) {
CteTable sqmCteTable, return new CteTable( sqmCteTable.getTableExpression(), sqmCteColumns );
List<CteColumn> sqmCteColumns,
SessionFactoryImplementor factory) {
return new CteTable(
sqmCteTable.getTableExpression(),
sqmCteColumns
);
} }
public SqmInsertStatement<?> getSqmStatement() { public SqmInsertStatement<?> getSqmStatement() {
@ -327,11 +320,7 @@ public class CteInsertHandler implements InsertHandler {
targetPathCteColumns.add( rowNumberColumn ); targetPathCteColumns.add( rowNumberColumn );
} }
final CteTable entityCteTable = createCteTable( final CteTable entityCteTable = createCteTable( getCteTable(), targetPathCteColumns );
getCteTable(),
targetPathCteColumns,
factory
);
// Create the main query spec that will return the count of rows // Create the main query spec that will return the count of rows
final QuerySpec querySpec = new QuerySpec( true, 1 ); final QuerySpec querySpec = new QuerySpec( true, 1 );
@ -502,11 +491,7 @@ public class CteInsertHandler implements InsertHandler {
} }
else { else {
targetPathCteColumns.add( 0, getCteTable().getCteColumns().get( 0 ) ); targetPathCteColumns.add( 0, getCteTable().getCteColumns().get( 0 ) );
finalEntityCteTable = createCteTable( finalEntityCteTable = createCteTable( getCteTable(), targetPathCteColumns );
getCteTable(),
targetPathCteColumns,
factory
);
} }
final List<CteColumn> cteColumns = finalEntityCteTable.getCteColumns(); final List<CteColumn> cteColumns = finalEntityCteTable.getCteColumns();
for ( int i = 1; i < cteColumns.size(); i++ ) { for ( int i = 1; i < cteColumns.size(); i++ ) {
@ -545,11 +530,7 @@ public class CteInsertHandler implements InsertHandler {
); );
statement.addCteStatement( baseEntityCte ); statement.addCteStatement( baseEntityCte );
targetPathCteColumns.add( 0, cteTable.getCteColumns().get( 0 ) ); targetPathCteColumns.add( 0, cteTable.getCteColumns().get( 0 ) );
final CteTable finalEntityCteTable = createCteTable( final CteTable finalEntityCteTable = createCteTable( getCteTable(), targetPathCteColumns );
getCteTable(),
targetPathCteColumns,
factory
);
final QuerySpec finalQuerySpec = new QuerySpec( true ); final QuerySpec finalQuerySpec = new QuerySpec( true );
final SelectStatement finalQueryStatement = new SelectStatement( finalQuerySpec ); final SelectStatement finalQueryStatement = new SelectStatement( finalQuerySpec );
entityCte = new CteStatement( entityCte = new CteStatement(
@ -719,7 +700,7 @@ public class CteInsertHandler implements InsertHandler {
// Add the root insert as cte // Add the root insert as cte
final AbstractEntityPersister persister = (AbstractEntityPersister) entityDescriptor.getEntityPersister(); final EntityPersister persister = entityDescriptor.getEntityPersister();
final String rootTableName = persister.getTableName( 0 ); final String rootTableName = persister.getTableName( 0 );
final TableReference rootTableReference = updatingTableGroup.getTableReference( final TableReference rootTableReference = updatingTableGroup.getTableReference(
updatingTableGroup.getNavigablePath(), updatingTableGroup.getNavigablePath(),
@ -1093,9 +1074,8 @@ public class CteInsertHandler implements InsertHandler {
List<String> columnsToMatch; List<String> columnsToMatch;
if ( constraintColumnNames.isEmpty() ) { if ( constraintColumnNames.isEmpty() ) {
// Assume the primary key columns // Assume the primary key columns
final AbstractEntityPersister aep = (AbstractEntityPersister) entityDescriptor;
Predicate predicate = buildColumnMatchPredicate( Predicate predicate = buildColumnMatchPredicate(
columnsToMatch = Arrays.asList( aep.getKeyColumns( tableIndex ) ), columnsToMatch = Arrays.asList( ( (EntityPersister) entityDescriptor).getKeyColumns( tableIndex ) ),
insertStatement, insertStatement,
false, false,
true true

View File

@ -17,7 +17,6 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.SemanticException; import org.hibernate.query.SemanticException;
import org.hibernate.query.results.TableGroupImpl; import org.hibernate.query.results.TableGroupImpl;
@ -80,7 +79,7 @@ public class CteUpdateHandler extends AbstractCteMutationHandler implements Upda
final SqmUpdateStatement<?> updateStatement = (SqmUpdateStatement<?>) getSqmDeleteOrUpdateStatement(); final SqmUpdateStatement<?> updateStatement = (SqmUpdateStatement<?>) getSqmDeleteOrUpdateStatement();
final EntityMappingType entityDescriptor = getEntityDescriptor(); final EntityMappingType entityDescriptor = getEntityDescriptor();
final AbstractEntityPersister entityPersister = (AbstractEntityPersister) entityDescriptor.getEntityPersister(); final EntityPersister entityPersister = entityDescriptor.getEntityPersister();
final String rootEntityName = entityPersister.getRootEntityName(); final String rootEntityName = entityPersister.getRootEntityName();
final EntityPersister rootEntityDescriptor = factory.getRuntimeMetamodels() final EntityPersister rootEntityDescriptor = factory.getRuntimeMetamodels()
.getMappingMetamodel() .getMappingMetamodel()

View File

@ -23,7 +23,6 @@ import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping; import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping;
import org.hibernate.metamodel.mapping.MappingModelExpressible; import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.SelectableConsumer;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.SemanticException; import org.hibernate.query.SemanticException;
import org.hibernate.query.spi.DomainQueryExecutionContext; import org.hibernate.query.spi.DomainQueryExecutionContext;
@ -268,7 +267,7 @@ public class InlineUpdateHandler implements UpdateHandler {
return; return;
} }
// Otherwise we have to check if the table is nullable, and if so, insert into that table // Otherwise we have to check if the table is nullable, and if so, insert into that table
final AbstractEntityPersister entityPersister = (AbstractEntityPersister) entityDescriptor.getEntityPersister(); final EntityPersister entityPersister = entityDescriptor.getEntityPersister();
boolean isNullable = false; boolean isNullable = false;
for (int i = 0; i < entityPersister.getTableSpan(); i++) { for (int i = 0; i < entityPersister.getTableSpan(); i++) {
if ( tableExpression.equals( entityPersister.getTableName( i ) ) && entityPersister.isNullableTable( i ) ) { if ( tableExpression.equals( entityPersister.getTableName( i ) ) && entityPersister.isNullableTable( i ) ) {

View File

@ -38,7 +38,6 @@ import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.MappingModelExpressible; import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.metamodel.mapping.ModelPartContainer; import org.hibernate.metamodel.mapping.ModelPartContainer;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.mutation.EntityMutationTarget; import org.hibernate.persister.entity.mutation.EntityMutationTarget;
import org.hibernate.query.SemanticException; import org.hibernate.query.SemanticException;
@ -218,7 +217,7 @@ public class InsertExecutionDelegate implements TableBasedInsertHandler.Executio
); );
if ( rows != 0 ) { if ( rows != 0 ) {
final AbstractEntityPersister persister = (AbstractEntityPersister) entityDescriptor.getEntityPersister(); final EntityPersister persister = entityDescriptor.getEntityPersister();
final int tableSpan = persister.getTableSpan(); final int tableSpan = persister.getTableSpan();
final int insertedRows = insertRootTable( final int insertedRows = insertRootTable(
persister.getTableName( 0 ), persister.getTableName( 0 ),
@ -726,7 +725,7 @@ public class InsertExecutionDelegate implements TableBasedInsertHandler.Executio
} }
} }
final String targetKeyColumnName = keyColumns[0]; final String targetKeyColumnName = keyColumns[0];
final AbstractEntityPersister entityPersister = (AbstractEntityPersister) entityDescriptor.getEntityPersister(); final EntityPersister entityPersister = entityDescriptor.getEntityPersister();
final Generator identifierGenerator = entityPersister.getGenerator(); final Generator identifierGenerator = entityPersister.getGenerator();
final boolean needsKeyInsert; final boolean needsKeyInsert;
if ( identifierGenerator.generatedOnExecution() ) { if ( identifierGenerator.generatedOnExecution() ) {

View File

@ -25,7 +25,7 @@ import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.metamodel.mapping.ModelPartContainer; import org.hibernate.metamodel.mapping.ModelPartContainer;
import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.SelectableConsumer;
import org.hibernate.metamodel.mapping.SoftDeleteMapping; import org.hibernate.metamodel.mapping.SoftDeleteMapping;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.SemanticException; import org.hibernate.query.SemanticException;
import org.hibernate.query.results.TableGroupImpl; import org.hibernate.query.results.TableGroupImpl;
import org.hibernate.query.spi.DomainQueryExecutionContext; import org.hibernate.query.spi.DomainQueryExecutionContext;
@ -299,7 +299,7 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio
} }
protected boolean isTableOptional(String tableExpression) { protected boolean isTableOptional(String tableExpression) {
final AbstractEntityPersister entityPersister = (AbstractEntityPersister) entityDescriptor.getEntityPersister(); final EntityPersister entityPersister = entityDescriptor.getEntityPersister();
for ( int i = 0; i < entityPersister.getTableSpan(); i++ ) { for ( int i = 0; i < entityPersister.getTableSpan(); i++ ) {
if ( tableExpression.equals( entityPersister.getTableName( i ) ) if ( tableExpression.equals( entityPersister.getTableName( i ) )
&& entityPersister.isNullableTable( i ) ) { && entityPersister.isNullableTable( i ) ) {

View File

@ -108,7 +108,6 @@ import org.hibernate.metamodel.model.domain.internal.EmbeddedSqmPathSource;
import org.hibernate.metamodel.model.domain.internal.EntityDiscriminatorSqmPath; import org.hibernate.metamodel.model.domain.internal.EntityDiscriminatorSqmPath;
import org.hibernate.metamodel.model.domain.internal.EntityTypeImpl; import org.hibernate.metamodel.model.domain.internal.EntityTypeImpl;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor; import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityNameUse; import org.hibernate.persister.entity.EntityNameUse;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.BindableType; import org.hibernate.query.BindableType;
@ -3073,7 +3072,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
EntityNameUse entityNameUse, EntityNameUse entityNameUse,
String treatTargetTypeName, String treatTargetTypeName,
boolean projection) { boolean projection) {
final AbstractEntityPersister persister; final EntityPersister persister;
if ( tableGroup.getModelPart() instanceof EmbeddableValuedModelPart ) { if ( tableGroup.getModelPart() instanceof EmbeddableValuedModelPart ) {
persister = null; persister = null;
final EmbeddableDomainType<?> embeddableDomainType = creationContext.getSessionFactory() final EmbeddableDomainType<?> embeddableDomainType = creationContext.getSessionFactory()
@ -3085,11 +3084,10 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
} }
} }
else { else {
persister = (AbstractEntityPersister) creationContext.getSessionFactory() persister = (EntityPersister) creationContext.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel() .getMappingMetamodel()
.findEntityDescriptor( treatTargetTypeName ); .findEntityDescriptor( treatTargetTypeName );
if ( persister == null || !persister.isPolymorphic() ) { if ( persister == null || !persister.getEntityMetamodel().isPolymorphic() ) {
return; return;
} }
} }
@ -3140,10 +3138,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
EntityMappingType superMappingType = persister; EntityMappingType superMappingType = persister;
while ( ( superMappingType = superMappingType.getSuperMappingType() ) != null ) { while ( ( superMappingType = superMappingType.getSuperMappingType() ) != null ) {
entityNameUses.putIfAbsent( superMappingType.getEntityName(), EntityNameUse.PROJECTION ); entityNameUses.putIfAbsent( superMappingType.getEntityName(), EntityNameUse.PROJECTION );
actualTableGroup.resolveTableReference( actualTableGroup.resolveTableReference( null, superMappingType.getEntityPersister().getTableName() );
null,
( (AbstractEntityPersister) superMappingType.getEntityPersister() ).getTableName()
);
} }
} }
@ -3205,7 +3200,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
final MappingType partMappingType = tableGroup.getModelPart().getPartMappingType(); final MappingType partMappingType = tableGroup.getModelPart().getPartMappingType();
if ( partMappingType instanceof EntityMappingType ) { if ( partMappingType instanceof EntityMappingType ) {
final EntityMappingType mappingType = (EntityMappingType) partMappingType; final EntityMappingType mappingType = (EntityMappingType) partMappingType;
final AbstractEntityPersister persister = (AbstractEntityPersister) mappingType.getEntityPersister(); final EntityPersister persister = mappingType.getEntityPersister();
// Avoid resolving subclass tables for persisters with physical discriminators as we won't need them // Avoid resolving subclass tables for persisters with physical discriminators as we won't need them
if ( persister.getDiscriminatorMapping().hasPhysicalColumn() ) { if ( persister.getDiscriminatorMapping().hasPhysicalColumn() ) {
return; return;
@ -5234,7 +5229,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
final TableGroup elementTableGroup = tableGroup instanceof PluralTableGroup final TableGroup elementTableGroup = tableGroup instanceof PluralTableGroup
? ( (PluralTableGroup) tableGroup ).getElementTableGroup() ? ( (PluralTableGroup) tableGroup ).getElementTableGroup()
: tableGroup; : tableGroup;
final AbstractEntityPersister persister = (AbstractEntityPersister) elementTableGroup.getModelPart().getPartMappingType(); final EntityPersister persister = (EntityPersister) elementTableGroup.getModelPart().getPartMappingType();
// Only need a case expression around the basic valued path for the parent treat expression // Only need a case expression around the basic valued path for the parent treat expression
// if the column of the basic valued path is shared between subclasses // if the column of the basic valued path is shared between subclasses
if ( persister.isSharedColumn( basicPath.getColumnReference().getColumnExpression() ) ) { if ( persister.isSharedColumn( basicPath.getColumnReference().getColumnExpression() ) ) {
@ -5434,8 +5429,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
} }
private Predicate createTreatTypeRestriction(SqmPath<?> lhs, EntityDomainType<?> treatTarget) { private Predicate createTreatTypeRestriction(SqmPath<?> lhs, EntityDomainType<?> treatTarget) {
final AbstractEntityPersister entityDescriptor = (AbstractEntityPersister) domainModel.findEntityDescriptor( treatTarget.getHibernateEntityName() ); final EntityPersister entityDescriptor = domainModel.findEntityDescriptor( treatTarget.getHibernateEntityName() );
if ( entityDescriptor.isPolymorphic() && lhs.getNodeType() != treatTarget ) { if ( entityDescriptor.getEntityMetamodel().isPolymorphic() && lhs.getNodeType() != treatTarget ) {
final Set<String> subclassEntityNames = entityDescriptor.getSubclassEntityNames(); final Set<String> subclassEntityNames = entityDescriptor.getSubclassEntityNames();
return createTreatTypeRestriction( lhs, subclassEntityNames ); return createTreatTypeRestriction( lhs, subclassEntityNames );
} }

View File

@ -57,7 +57,6 @@ import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.ModelPartContainer; import org.hibernate.metamodel.mapping.ModelPartContainer;
import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.metamodel.mapping.SqlTypedMapping; import org.hibernate.metamodel.mapping.SqlTypedMapping;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.internal.SqlFragmentPredicate; import org.hibernate.persister.internal.SqlFragmentPredicate;
import org.hibernate.query.IllegalQueryOperationException; import org.hibernate.query.IllegalQueryOperationException;
@ -5974,8 +5973,8 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
processNestedTableGroupJoins( tableGroup, null ); processNestedTableGroupJoins( tableGroup, null );
processTableGroupJoins( tableGroup ); processTableGroupJoins( tableGroup );
ModelPartContainer modelPart = tableGroup.getModelPart(); ModelPartContainer modelPart = tableGroup.getModelPart();
if ( modelPart instanceof AbstractEntityPersister ) { if ( modelPart instanceof EntityPersister ) {
String[] querySpaces = (String[]) ( (AbstractEntityPersister) modelPart ).getQuerySpaces(); String[] querySpaces = (String[]) ( (EntityPersister) modelPart ).getQuerySpaces();
for ( int i = 0; i < querySpaces.length; i++ ) { for ( int i = 0; i < querySpaces.length; i++ ) {
registerAffectedTable( querySpaces[i] ); registerAffectedTable( querySpaces[i] );
} }
@ -6017,8 +6016,8 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
processTableGroupJoins( tableGroup ); processTableGroupJoins( tableGroup );
} }
ModelPartContainer modelPart = tableGroup.getModelPart(); ModelPartContainer modelPart = tableGroup.getModelPart();
if ( modelPart instanceof AbstractEntityPersister ) { if ( modelPart instanceof EntityPersister ) {
String[] querySpaces = (String[]) ( (AbstractEntityPersister) modelPart ).getQuerySpaces(); String[] querySpaces = (String[]) ( (EntityPersister) modelPart ).getQuerySpaces();
for ( int i = 0; i < querySpaces.length; i++ ) { for ( int i = 0; i < querySpaces.length; i++ ) {
registerAffectedTable( querySpaces[i] ); registerAffectedTable( querySpaces[i] );
} }
@ -6100,8 +6099,8 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
} }
ModelPartContainer modelPart = tableGroup.getModelPart(); ModelPartContainer modelPart = tableGroup.getModelPart();
if ( modelPart instanceof AbstractEntityPersister ) { if ( modelPart instanceof EntityPersister ) {
String[] querySpaces = (String[]) ( (AbstractEntityPersister) modelPart ).getQuerySpaces(); String[] querySpaces = (String[]) ( (EntityPersister) modelPart ).getQuerySpaces();
for ( int i = 0; i < querySpaces.length; i++ ) { for ( int i = 0; i < querySpaces.length; i++ ) {
registerAffectedTable( querySpaces[i] ); registerAffectedTable( querySpaces[i] );
} }

View File

@ -14,7 +14,7 @@ import java.util.function.Consumer;
import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.SelectableConsumer;
import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.SelectableMapping;
import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.mutation.EntityMutationTarget; import org.hibernate.persister.entity.mutation.EntityMutationTarget;
import org.hibernate.sql.model.MutationType; import org.hibernate.sql.model.MutationType;
import org.hibernate.sql.model.ast.MutationGroup; import org.hibernate.sql.model.ast.MutationGroup;
@ -73,8 +73,7 @@ public class MutationGroupBuilder implements SelectableConsumer {
@Override @Override
public void accept(int selectionIndex, SelectableMapping selectableMapping) { public void accept(int selectionIndex, SelectableMapping selectableMapping) {
final AbstractEntityPersister entityPersister = (AbstractEntityPersister) mutationTarget.getTargetPart() final EntityPersister entityPersister = mutationTarget.getTargetPart().getEntityPersister();
.getEntityPersister();
final String tableNameForMutation = entityPersister.physicalTableNameForMutation( selectableMapping ); final String tableNameForMutation = entityPersister.physicalTableNameForMutation( selectableMapping );
final ColumnValuesTableMutationBuilder mutationBuilder = findTableDetailsBuilder( tableNameForMutation ); final ColumnValuesTableMutationBuilder mutationBuilder = findTableDetailsBuilder( tableNameForMutation );
mutationBuilder.addValueColumn( selectableMapping ); mutationBuilder.addValueColumn( selectableMapping );

View File

@ -15,7 +15,6 @@ import java.util.Set;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.hibernate.FetchMode;
import org.hibernate.Filter; import org.hibernate.Filter;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
@ -56,6 +55,7 @@ import org.hibernate.metamodel.mapping.EntityVersionMapping;
import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.NaturalIdMapping; import org.hibernate.metamodel.mapping.NaturalIdMapping;
import org.hibernate.metamodel.mapping.SelectableMapping;
import org.hibernate.metamodel.mapping.TableDetails; import org.hibernate.metamodel.mapping.TableDetails;
import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.metamodel.spi.EntityRepresentationStrategy; import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
@ -76,6 +76,7 @@ import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.predicate.Predicate; import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.model.ast.builder.MutationGroupBuilder;
import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
@ -919,16 +920,6 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
return new String[0]; return new String[0];
} }
@Override
public FetchMode getFetchMode(int i) {
return null;
}
@Override
public Type getSubclassPropertyType(int i) {
return null;
}
@Override @Override
public String[] getPropertyColumnNames(String propertyPath) { public String[] getPropertyColumnNames(String propertyPath) {
return new String[0]; return new String[0];
@ -948,6 +939,111 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
public String[] toColumns(String propertyName) { public String[] toColumns(String propertyName) {
return new String[0]; return new String[0];
} }
@Override
public boolean[] getNonLazyPropertyUpdateability() {
return new boolean[0];
}
@Override
public boolean hasMultipleTables() {
return false;
}
@Override
public String[] getTableNames() {
return new String[0];
}
@Override
public String getTableName(int j) {
return "";
}
@Override
public String[] getKeyColumns(int j) {
return new String[0];
}
@Override
public int getTableSpan() {
return 0;
}
@Override
public boolean isInverseTable(int j) {
return false;
}
@Override
public boolean isNullableTable(int j) {
return false;
}
@Override
public boolean hasDuplicateTables() {
return false;
}
@Override
public int getSubclassTableSpan() {
return 0;
}
@Override
public String getSubclassTableName(int j) {
return "";
}
@Override
public String getTableNameForColumn(String columnName) {
return "";
}
@Override
public String[] getSubclassPropertyColumnNames(int i) {
return new String[0];
}
@Override
public int countSubclassProperties() {
return 0;
}
@Override
public boolean isSharedColumn(String columnExpression) {
return false;
}
@Override
public String[][] getConstraintOrderedTableKeyColumnClosure() {
return new String[0][];
}
@Override
public EntityTableMapping[] getTableMappings() {
return new EntityTableMapping[0];
}
@Override
public String physicalTableNameForMutation(SelectableMapping selectableMapping) {
return "";
}
@Override
public void addDiscriminatorToInsertGroup(MutationGroupBuilder insertGroupBuilder) {
}
@Override
public void addSoftDeleteToInsertGroup(MutationGroupBuilder insertGroupBuilder) {
}
@Override
public String getAttributeMutationTableName(int i) {
return "";
}
} }
public static class NoopCollectionPersister implements CollectionPersister { public static class NoopCollectionPersister implements CollectionPersister {

View File

@ -15,7 +15,7 @@ import org.hibernate.annotations.FetchMode;
import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming; import org.hibernate.engine.FetchTiming;
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper; import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.type.AssociationType; import org.hibernate.type.AssociationType;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -172,17 +172,15 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
} }
private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) { private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) {
EntityPersister entityPersister = sessionFactory().getRuntimeMetamodels() AbstractEntityPersister entityPersister = (AbstractEntityPersister)
.getMappingMetamodel() sessionFactory().getMappingMetamodel().getEntityDescriptor(entityClass.getName());
.getEntityDescriptor(entityClass.getName());
int index = entityPersister.getPropertyIndex( path ); int index = entityPersister.getPropertyIndex( path );
return entityPersister.getFetchMode( index ); return entityPersister.getFetchMode( index );
} }
private AssociationType determineAssociationType(Class<?> entityClass, String path) { private AssociationType determineAssociationType(Class<?> entityClass, String path) {
EntityPersister entityPersister = sessionFactory().getRuntimeMetamodels() AbstractEntityPersister entityPersister = (AbstractEntityPersister)
.getMappingMetamodel() sessionFactory().getMappingMetamodel().getEntityDescriptor(entityClass.getName());
.getEntityDescriptor(entityClass.getName());
int index = entityPersister.getPropertyIndex( path ); int index = entityPersister.getPropertyIndex( path );
return (AssociationType) entityPersister.getSubclassPropertyType( index ); return (AssociationType) entityPersister.getSubclassPropertyType( index );
} }

View File

@ -14,7 +14,7 @@ import org.hibernate.annotations.FetchMode;
import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming; import org.hibernate.engine.FetchTiming;
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper; import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.type.AssociationType; import org.hibernate.type.AssociationType;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -168,17 +168,15 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
} }
private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) { private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) {
EntityPersister entityPersister = sessionFactory().getRuntimeMetamodels() AbstractEntityPersister entityPersister = (AbstractEntityPersister)
.getMappingMetamodel() sessionFactory().getMappingMetamodel().getEntityDescriptor(entityClass.getName());
.getEntityDescriptor(entityClass.getName());
int index = entityPersister.getPropertyIndex( path ); int index = entityPersister.getPropertyIndex( path );
return entityPersister.getFetchMode( index ); return entityPersister.getFetchMode( index );
} }
private AssociationType determineAssociationType(Class<?> entityClass, String path) { private AssociationType determineAssociationType(Class<?> entityClass, String path) {
EntityPersister entityPersister = sessionFactory().getRuntimeMetamodels() AbstractEntityPersister entityPersister = (AbstractEntityPersister)
.getMappingMetamodel() sessionFactory().getMappingMetamodel().getEntityDescriptor(entityClass.getName());
.getEntityDescriptor(entityClass.getName());
int index = entityPersister.getPropertyIndex( path ); int index = entityPersister.getPropertyIndex( path );
return (AssociationType) entityPersister.getSubclassPropertyType( index ); return (AssociationType) entityPersister.getSubclassPropertyType( index );
} }

View File

@ -12,7 +12,7 @@ import org.hibernate.annotations.Proxy;
import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming; import org.hibernate.engine.FetchTiming;
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper; import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.type.AssociationType; import org.hibernate.type.AssociationType;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -89,17 +89,15 @@ public class NoProxyFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
} }
private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) { private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) {
EntityPersister entityPersister = sessionFactory().getRuntimeMetamodels() AbstractEntityPersister entityPersister = (AbstractEntityPersister)
.getMappingMetamodel() sessionFactory().getMappingMetamodel().getEntityDescriptor(entityClass.getName());
.getEntityDescriptor(entityClass.getName());
int index = entityPersister.getPropertyIndex( path ); int index = entityPersister.getPropertyIndex( path );
return entityPersister.getFetchMode( index ); return entityPersister.getFetchMode( index );
} }
private AssociationType determineAssociationType(Class<?> entityClass, String path) { private AssociationType determineAssociationType(Class<?> entityClass, String path) {
EntityPersister entityPersister = sessionFactory().getRuntimeMetamodels() AbstractEntityPersister entityPersister = (AbstractEntityPersister)
.getMappingMetamodel() sessionFactory().getMappingMetamodel().getEntityDescriptor(entityClass.getName());
.getEntityDescriptor(entityClass.getName());
int index = entityPersister.getPropertyIndex( path ); int index = entityPersister.getPropertyIndex( path );
return (AssociationType) entityPersister.getSubclassPropertyType( index ); return (AssociationType) entityPersister.getSubclassPropertyType( index );
} }

View File

@ -15,7 +15,6 @@ import java.util.Map;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.hibernate.FetchMode;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
@ -54,6 +53,7 @@ import org.hibernate.metamodel.mapping.EntityVersionMapping;
import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.NaturalIdMapping; import org.hibernate.metamodel.mapping.NaturalIdMapping;
import org.hibernate.metamodel.mapping.SelectableMapping;
import org.hibernate.metamodel.mapping.TableDetails; import org.hibernate.metamodel.mapping.TableDetails;
import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.metamodel.spi.EntityRepresentationStrategy; import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
@ -74,6 +74,7 @@ import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.spi.NavigablePath; import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.model.ast.builder.MutationGroupBuilder;
import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
@ -950,16 +951,6 @@ public class PersisterClassProviderTest {
return new String[0]; return new String[0];
} }
@Override
public FetchMode getFetchMode(int i) {
return null;
}
@Override
public Type getSubclassPropertyType(int i) {
return null;
}
@Override @Override
public String[] getPropertyColumnNames(String propertyPath) { public String[] getPropertyColumnNames(String propertyPath) {
return new String[0]; return new String[0];
@ -979,6 +970,111 @@ public class PersisterClassProviderTest {
public String[] toColumns(String propertyName) { public String[] toColumns(String propertyName) {
return new String[0]; return new String[0];
} }
@Override
public boolean[] getNonLazyPropertyUpdateability() {
return new boolean[0];
}
@Override
public boolean hasMultipleTables() {
return false;
}
@Override
public String[] getTableNames() {
return new String[0];
}
@Override
public String getTableName(int j) {
return "";
}
@Override
public String[] getKeyColumns(int j) {
return new String[0];
}
@Override
public int getTableSpan() {
return 0;
}
@Override
public boolean isInverseTable(int j) {
return false;
}
@Override
public boolean isNullableTable(int j) {
return false;
}
@Override
public boolean hasDuplicateTables() {
return false;
}
@Override
public int getSubclassTableSpan() {
return 0;
}
@Override
public String getSubclassTableName(int j) {
return "";
}
@Override
public String getTableNameForColumn(String columnName) {
return "";
}
@Override
public String[] getSubclassPropertyColumnNames(int i) {
return new String[0];
}
@Override
public int countSubclassProperties() {
return 0;
}
@Override
public boolean isSharedColumn(String columnExpression) {
return false;
}
@Override
public String[][] getConstraintOrderedTableKeyColumnClosure() {
return new String[0][];
}
@Override
public EntityTableMapping[] getTableMappings() {
return new EntityTableMapping[0];
}
@Override
public String physicalTableNameForMutation(SelectableMapping selectableMapping) {
return "";
}
@Override
public void addDiscriminatorToInsertGroup(MutationGroupBuilder insertGroupBuilder) {
}
@Override
public void addSoftDeleteToInsertGroup(MutationGroupBuilder insertGroupBuilder) {
}
@Override
public String getAttributeMutationTableName(int i) {
return "";
}
} }
public static class GoofyException extends RuntimeException { public static class GoofyException extends RuntimeException {

View File

@ -15,7 +15,6 @@ import java.util.Objects;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.hibernate.FetchMode;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
@ -55,6 +54,7 @@ import org.hibernate.metamodel.mapping.EntityVersionMapping;
import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.NaturalIdMapping; import org.hibernate.metamodel.mapping.NaturalIdMapping;
import org.hibernate.metamodel.mapping.SelectableMapping;
import org.hibernate.metamodel.mapping.TableDetails; import org.hibernate.metamodel.mapping.TableDetails;
import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.metamodel.spi.EntityRepresentationStrategy; import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
@ -72,6 +72,7 @@ import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.model.MutationOperationGroup; import org.hibernate.sql.model.MutationOperationGroup;
import org.hibernate.sql.model.ast.builder.MutationGroupBuilder;
import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
@ -1058,16 +1059,6 @@ public class CustomPersister implements EntityPersister {
return new String[0]; return new String[0];
} }
@Override
public FetchMode getFetchMode(int i) {
return null;
}
@Override
public Type getSubclassPropertyType(int i) {
return null;
}
@Override @Override
public String[] getPropertyColumnNames(String propertyPath) { public String[] getPropertyColumnNames(String propertyPath) {
return new String[0]; return new String[0];
@ -1087,4 +1078,109 @@ public class CustomPersister implements EntityPersister {
public String[] toColumns(String propertyName) { public String[] toColumns(String propertyName) {
return new String[0]; return new String[0];
} }
@Override
public boolean[] getNonLazyPropertyUpdateability() {
return new boolean[0];
}
@Override
public boolean hasMultipleTables() {
return false;
}
@Override
public String[] getTableNames() {
return new String[0];
}
@Override
public String getTableName(int j) {
return "";
}
@Override
public String[] getKeyColumns(int j) {
return new String[0];
}
@Override
public int getTableSpan() {
return 0;
}
@Override
public boolean isInverseTable(int j) {
return false;
}
@Override
public boolean isNullableTable(int j) {
return false;
}
@Override
public boolean hasDuplicateTables() {
return false;
}
@Override
public int getSubclassTableSpan() {
return 0;
}
@Override
public String getSubclassTableName(int j) {
return "";
}
@Override
public String getTableNameForColumn(String columnName) {
return "";
}
@Override
public String[] getSubclassPropertyColumnNames(int i) {
return new String[0];
}
@Override
public int countSubclassProperties() {
return 0;
}
@Override
public boolean isSharedColumn(String columnExpression) {
return false;
}
@Override
public String[][] getConstraintOrderedTableKeyColumnClosure() {
return new String[0][];
}
@Override
public EntityTableMapping[] getTableMappings() {
return new EntityTableMapping[0];
}
@Override
public String physicalTableNameForMutation(SelectableMapping selectableMapping) {
return "";
}
@Override
public void addDiscriminatorToInsertGroup(MutationGroupBuilder insertGroupBuilder) {
}
@Override
public void addSoftDeleteToInsertGroup(MutationGroupBuilder insertGroupBuilder) {
}
@Override
public String getAttributeMutationTableName(int i) {
return "";
}
} }

View File

@ -12,8 +12,8 @@ import jakarta.persistence.MapsId;
import jakarta.persistence.OneToOne; import jakarta.persistence.OneToOne;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.mutation.UpdateCoordinatorStandard;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.logger.LoggerInspectionRule; import org.hibernate.testing.logger.LoggerInspectionRule;
import org.hibernate.testing.logger.Triggerable; import org.hibernate.testing.logger.Triggerable;
@ -43,7 +43,7 @@ public class OneToOneMapsIdChangeParentTest {
public LoggerInspectionRule logInspection = new LoggerInspectionRule( public LoggerInspectionRule logInspection = new LoggerInspectionRule(
Logger.getMessageLogger( Logger.getMessageLogger(
CoreMessageLogger.class, CoreMessageLogger.class,
AbstractEntityPersister.class.getName() UpdateCoordinatorStandard.class.getName()
) )
); );