HHH-16353 Make it possible for Hibernate Reactive to override the creation of AttributeMapping and Fetch strategies

This commit is contained in:
Davide D'Alto 2023-03-22 16:09:46 +01:00 committed by Davide D'Alto
parent 837d1a32cb
commit d63ff31b59
10 changed files with 429 additions and 63 deletions

View File

@ -27,6 +27,11 @@ public abstract class AbstractAttributeMapping implements AttributeMapping {
this.declaringType = declaringType; this.declaringType = declaringType;
} }
// For Hibernate Reactive
protected AbstractAttributeMapping(AbstractAttributeMapping original) {
this( original.name, original.fetchableIndex, original.declaringType );
}
@Override @Override
public ManagedMappingType getDeclaringType() { public ManagedMappingType getDeclaringType() {
return declaringType; return declaringType;

View File

@ -23,6 +23,7 @@ import org.hibernate.metamodel.mapping.AssociationKey;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping; import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.PropertyMapping; import org.hibernate.persister.entity.PropertyMapping;
@ -41,6 +42,7 @@ import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.FetchOptions; import org.hibernate.sql.results.graph.FetchOptions;
import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.graph.FetchParent;
import org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch;
import org.hibernate.sql.results.graph.entity.EntityFetch; import org.hibernate.sql.results.graph.entity.EntityFetch;
import org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl; import org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl;
import org.hibernate.type.CompositeType; import org.hibernate.type.CompositeType;
@ -82,6 +84,16 @@ public abstract class AbstractEntityCollectionPart implements EntityCollectionPa
); );
} }
// For Hibernate Reactive
protected AbstractEntityCollectionPart(AbstractEntityCollectionPart original) {
this.navigableRole = original.navigableRole;
this.nature = original.nature;
this.collectionDescriptor = original.collectionDescriptor;
this.associatedEntityTypeDescriptor = original.associatedEntityTypeDescriptor;
this.notFoundAction = original.notFoundAction;
this.targetKeyPropertyNames = original.targetKeyPropertyNames;
}
@Override @Override
public String toString() { public String toString() {
return "EntityCollectionPart(" + navigableRole.getFullPath() + ")@" + System.identityHashCode( this ); return "EntityCollectionPart(" + navigableRole.getFullPath() + ")@" + System.identityHashCode( this );
@ -193,7 +205,7 @@ public abstract class AbstractEntityCollectionPart implements EntityCollectionPa
final boolean added = creationState.registerVisitedAssociationKey( associationKey ); final boolean added = creationState.registerVisitedAssociationKey( associationKey );
final TableGroup partTableGroup = resolveTableGroup( fetchablePath, creationState ); final TableGroup partTableGroup = resolveTableGroup( fetchablePath, creationState );
final EntityFetchJoinedImpl fetch = new EntityFetchJoinedImpl( final EntityFetch fetch = buildEntityFetchJoined(
fetchParent, fetchParent,
this, this,
partTableGroup, partTableGroup,
@ -208,6 +220,38 @@ public abstract class AbstractEntityCollectionPart implements EntityCollectionPa
return fetch; return fetch;
} }
// For Hibernate Reactive
protected EagerCollectionFetch buildEagerCollectionFetch(
NavigablePath fetchedPath,
PluralAttributeMapping fetchedAttribute,
TableGroup collectionTableGroup,
FetchParent fetchParent,
DomainResultCreationState creationState) {
return new EagerCollectionFetch(
fetchedPath,
fetchedAttribute,
collectionTableGroup,
fetchParent,
creationState
);
}
// For Hibernate Reactive
protected EntityFetch buildEntityFetchJoined(
FetchParent fetchParent,
AbstractEntityCollectionPart abstractEntityCollectionPart,
TableGroup partTableGroup,
NavigablePath fetchablePath,
DomainResultCreationState creationState) {
return new EntityFetchJoinedImpl(
fetchParent,
abstractEntityCollectionPart,
partTableGroup,
fetchablePath,
creationState
);
}
protected abstract AssociationKey resolveFetchAssociationKey(); protected abstract AssociationKey resolveFetchAssociationKey();
private TableGroup resolveTableGroup(NavigablePath fetchablePath, DomainResultCreationState creationState) { private TableGroup resolveTableGroup(NavigablePath fetchablePath, DomainResultCreationState creationState) {

View File

@ -49,6 +49,12 @@ public abstract class AbstractSingularAttributeMapping
this.propertyAccess = propertyAccess; this.propertyAccess = propertyAccess;
} }
// For Hibernate Reactive
protected AbstractSingularAttributeMapping( AbstractSingularAttributeMapping original ) {
super( original );
this.propertyAccess = original.propertyAccess;
}
@Override @Override
public PropertyAccess getPropertyAccess() { public PropertyAccess getPropertyAccess() {
return propertyAccess; return propertyAccess;

View File

@ -57,6 +57,16 @@ public abstract class AbstractStateArrayContributorMapping
); );
} }
// For Hibernate Reactive
protected AbstractStateArrayContributorMapping(AbstractStateArrayContributorMapping original) {
super( original );
this.attributeMetadata = original.attributeMetadata;
this.fetchTiming = original.fetchTiming;
this.fetchStyle = original.fetchStyle;
this.stateArrayPosition = original.stateArrayPosition;
}
@Override @Override
public int getStateArrayPosition() { public int getStateArrayPosition() {
return stateArrayPosition; return stateArrayPosition;

View File

@ -12,6 +12,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.SortedMap; import java.util.SortedMap;
import java.util.SortedSet; import java.util.SortedSet;
import java.util.function.Function;
import org.hibernate.FetchMode; import org.hibernate.FetchMode;
import org.hibernate.MappingException; import org.hibernate.MappingException;
@ -431,6 +432,33 @@ public class MappingModelCreationHelper {
CascadeStyle cascadeStyle, CascadeStyle cascadeStyle,
FetchMode fetchMode, FetchMode fetchMode,
MappingModelCreationProcess creationProcess) { MappingModelCreationProcess creationProcess) {
return buildPluralAttributeMapping(
attrName,
stateArrayPosition,
fetchableIndex,
bootProperty,
declaringType,
propertyAccess,
cascadeStyle,
fetchMode,
creationProcess,
Function.identity()
);
}
@SuppressWarnings("rawtypes")
public static PluralAttributeMapping buildPluralAttributeMapping(
String attrName,
int stateArrayPosition,
int fetchableIndex,
Property bootProperty,
ManagedMappingType declaringType,
PropertyAccess propertyAccess,
CascadeStyle cascadeStyle,
FetchMode fetchMode,
MappingModelCreationProcess creationProcess,
// For Hibernate Reactive
Function<PluralAttributeMappingImpl, PluralAttributeMappingImpl> mappingConverter) {
final Collection bootValueMapping = (Collection) bootProperty.getValue(); final Collection bootValueMapping = (Collection) bootProperty.getValue();
@ -625,7 +653,8 @@ public class MappingModelCreationHelper {
sessionFactory sessionFactory
); );
final PluralAttributeMappingImpl pluralAttributeMapping = new PluralAttributeMappingImpl( final PluralAttributeMappingImpl pluralAttributeMapping = mappingConverter
.apply( new PluralAttributeMappingImpl(
attrName, attrName,
bootValueMapping, bootValueMapping,
propertyAccess, propertyAccess,
@ -641,12 +670,16 @@ public class MappingModelCreationHelper {
cascadeStyle, cascadeStyle,
declaringType, declaringType,
collectionDescriptor collectionDescriptor
); ) );
creationProcess.registerInitializationCallback( creationProcess.registerInitializationCallback(
"PluralAttributeMapping(" + bootValueMapping.getRole() + ")#finishInitialization", "PluralAttributeMapping(" + bootValueMapping.getRole() + ")#finishInitialization",
() -> { () -> {
pluralAttributeMapping.finishInitialization( bootProperty, bootValueMapping, creationProcess ); pluralAttributeMapping.finishInitialization(
bootProperty,
bootValueMapping,
creationProcess
);
return true; return true;
} }
); );
@ -1550,6 +1583,7 @@ public class MappingModelCreationHelper {
} }
} }
// For Hibernate Reactive
public static ToOneAttributeMapping buildSingularAssociationAttributeMapping( public static ToOneAttributeMapping buildSingularAssociationAttributeMapping(
String attrName, String attrName,
NavigableRole navigableRole, NavigableRole navigableRole,
@ -1562,6 +1596,35 @@ public class MappingModelCreationHelper {
PropertyAccess propertyAccess, PropertyAccess propertyAccess,
CascadeStyle cascadeStyle, CascadeStyle cascadeStyle,
MappingModelCreationProcess creationProcess) { MappingModelCreationProcess creationProcess) {
return buildSingularAssociationAttributeMapping(
attrName,
navigableRole,
stateArrayPosition,
fetchableIndex,
bootProperty,
declaringType,
declaringEntityPersister,
attrType,
propertyAccess,
cascadeStyle,
creationProcess,
Function.identity()
);
}
public static ToOneAttributeMapping buildSingularAssociationAttributeMapping(
String attrName,
NavigableRole navigableRole,
int stateArrayPosition,
int fetchableIndex,
Property bootProperty,
ManagedMappingType declaringType,
EntityPersister declaringEntityPersister,
EntityType attrType,
PropertyAccess propertyAccess,
CascadeStyle cascadeStyle,
MappingModelCreationProcess creationProcess,
Function<ToOneAttributeMapping, ToOneAttributeMapping> mappingConverter) {
if ( bootProperty.getValue() instanceof ToOne ) { if ( bootProperty.getValue() instanceof ToOne ) {
final ToOne value = (ToOne) bootProperty.getValue(); final ToOne value = (ToOne) bootProperty.getValue();
final EntityPersister entityPersister = creationProcess.getEntityPersister( value.getReferencedEntityName() ); final EntityPersister entityPersister = creationProcess.getEntityPersister( value.getReferencedEntityName() );
@ -1614,7 +1677,7 @@ public class MappingModelCreationHelper {
fetchTiming = FetchOptionsHelper.determineFetchTiming( fetchStyle, type, lazy, role, sessionFactory ); fetchTiming = FetchOptionsHelper.determineFetchTiming( fetchStyle, type, lazy, role, sessionFactory );
} }
final ToOneAttributeMapping attributeMapping = new ToOneAttributeMapping( final ToOneAttributeMapping attributeMapping = mappingConverter.apply( new ToOneAttributeMapping(
attrName, attrName,
navigableRole, navigableRole,
stateArrayPosition, stateArrayPosition,
@ -1627,7 +1690,7 @@ public class MappingModelCreationHelper {
declaringType, declaringType,
declaringEntityPersister, declaringEntityPersister,
propertyAccess propertyAccess
); ) );
creationProcess.registerForeignKeyPostInitCallbacks( creationProcess.registerForeignKeyPostInitCallbacks(
"To-one key - " + navigableRole, "To-one key - " + navigableRole,

View File

@ -73,6 +73,12 @@ public class OneToManyCollectionPart extends AbstractEntityCollectionPart implem
} }
} }
protected OneToManyCollectionPart(OneToManyCollectionPart original) {
super( original );
this.mapKeyPropertyName = original.mapKeyPropertyName;
this.fetchAssociationKey = original.fetchAssociationKey;
}
@Override @Override
public Cardinality getCardinality() { public Cardinality getCardinality() {
return Cardinality.ONE_TO_MANY; return Cardinality.ONE_TO_MANY;

View File

@ -190,16 +190,49 @@ public class PluralAttributeMappingImpl
} }
}; };
injectAttributeMapping( elementDescriptor, indexDescriptor, collectionDescriptor, this );
}
// For Hibernate Reactive
protected PluralAttributeMappingImpl(PluralAttributeMappingImpl original) {
super( original );
this.propertyAccess = original.propertyAccess;
this.attributeMetadata = original.attributeMetadata;
this.collectionMappingType = original.collectionMappingType;
this.stateArrayPosition = original.stateArrayPosition;
this.elementDescriptor = original.elementDescriptor;
this.indexDescriptor = original.indexDescriptor;
this.identifierDescriptor = original.identifierDescriptor;
this.fetchTiming = original.fetchTiming;
this.fetchStyle = original.fetchStyle;
this.collectionDescriptor = original.collectionDescriptor;
this.referencedPropertyName = original.referencedPropertyName;
this.mapKeyPropertyName = original.mapKeyPropertyName;
this.bidirectionalAttributeName = original.bidirectionalAttributeName;
this.sqlAliasStem = original.sqlAliasStem;
this.separateCollectionTable = original.separateCollectionTable;
this.indexMetadata = original.indexMetadata;
this.fkDescriptor = original.fkDescriptor;
this.orderByFragment = original.orderByFragment;
this.manyToManyOrderByFragment = original.manyToManyOrderByFragment;
injectAttributeMapping( elementDescriptor, indexDescriptor, collectionDescriptor, this );
}
private static void injectAttributeMapping(
CollectionPart elementDescriptor,
CollectionPart indexDescriptor,
CollectionPersister collectionDescriptor,
PluralAttributeMapping mapping) {
if ( collectionDescriptor instanceof Aware ) { if ( collectionDescriptor instanceof Aware ) {
( (Aware) collectionDescriptor ).injectAttributeMapping( this ); ( (Aware) collectionDescriptor ).injectAttributeMapping( mapping );
} }
if ( elementDescriptor instanceof Aware ) { if ( elementDescriptor instanceof Aware ) {
( (Aware) elementDescriptor ).injectAttributeMapping( this ); ( (Aware) elementDescriptor ).injectAttributeMapping( mapping );
} }
if ( indexDescriptor instanceof Aware ) { if ( indexDescriptor instanceof Aware ) {
( (Aware) indexDescriptor ).injectAttributeMapping( this ); ( (Aware) indexDescriptor ).injectAttributeMapping( mapping );
} }
} }
@ -405,7 +438,7 @@ public class PluralAttributeMappingImpl
sqlAstCreationState sqlAstCreationState
); );
return new EagerCollectionFetch( return buildEagerCollectionFetch(
fetchablePath, fetchablePath,
this, this,
collectionTableGroup, collectionTableGroup,
@ -443,6 +476,40 @@ public class PluralAttributeMappingImpl
} }
} }
// For Hibernate Reactive
protected Fetch buildDelayedCollectionFetch(
NavigablePath fetchedPath,
PluralAttributeMapping fetchedAttribute,
FetchParent fetchParent,
DomainResult<?> collectionKeyResult) {
return new DelayedCollectionFetch( fetchedPath, fetchedAttribute, fetchParent, collectionKeyResult );
}
// For Hibernate Reactive
protected Fetch buildSelectEagerCollectionFetch(
NavigablePath fetchedPath,
PluralAttributeMapping fetchedAttribute,
DomainResult<?> collectionKeyDomainResult,
FetchParent fetchParent) {
return new SelectEagerCollectionFetch( fetchedPath, fetchedAttribute, collectionKeyDomainResult, fetchParent );
}
// For Hibernate Reactive
protected Fetch buildEagerCollectionFetch(
NavigablePath fetchedPath,
PluralAttributeMapping fetchedAttribute,
TableGroup collectionTableGroup,
FetchParent fetchParent,
DomainResultCreationState creationState) {
return new EagerCollectionFetch(
fetchedPath,
fetchedAttribute,
collectionTableGroup,
fetchParent,
creationState
);
}
@Override @Override
public Fetch resolveCircularFetch( public Fetch resolveCircularFetch(
NavigablePath fetchablePath, NavigablePath fetchablePath,
@ -481,7 +548,7 @@ public class PluralAttributeMappingImpl
else { else {
collectionKeyDomainResult = null; collectionKeyDomainResult = null;
} }
return new SelectEagerCollectionFetch( fetchablePath, this, collectionKeyDomainResult, fetchParent ); return buildSelectEagerCollectionFetch( fetchablePath, this, collectionKeyDomainResult, fetchParent );
} }
private TableGroup resolveCollectionTableGroup( private TableGroup resolveCollectionTableGroup(
@ -531,7 +598,7 @@ public class PluralAttributeMappingImpl
creationState creationState
); );
} }
return new DelayedCollectionFetch( return buildDelayedCollectionFetch(
fetchablePath, fetchablePath,
this, this,
fetchParent, fetchParent,

View File

@ -157,32 +157,29 @@ public class ToOneAttributeMapping
private String identifyingColumnsTableExpression; private String identifyingColumnsTableExpression;
private boolean canUseParentTableGroup; private boolean canUseParentTableGroup;
protected ToOneAttributeMapping(ToOneAttributeMapping delegate) { // For Hibernate Reactive
super( protected ToOneAttributeMapping(ToOneAttributeMapping original) {
delegate.getAttributeName(), super( original );
delegate.getStateArrayPosition(), navigableRole = original.navigableRole;
delegate.getFetchableKey(), isInternalLoadNullable = original.isInternalLoadNullable;
delegate.getAttributeMetadata(), notFoundAction = original.notFoundAction;
delegate.getMappedFetchOptions(), unwrapProxy = original.unwrapProxy;
delegate.getDeclaringType(), isOptional = original.isOptional;
delegate.getPropertyAccess() entityMappingType = original.entityMappingType;
); referencedPropertyName = original.referencedPropertyName;
navigableRole = delegate.navigableRole; targetKeyPropertyName = original.targetKeyPropertyName;
isInternalLoadNullable = delegate.isInternalLoadNullable; cardinality = original.cardinality;
notFoundAction = delegate.notFoundAction; bidirectionalAttributePath = original.bidirectionalAttributePath;
unwrapProxy = delegate.unwrapProxy; declaringTableGroupProducer = original.declaringTableGroupProducer;
isOptional = delegate.isOptional; isKeyTableNullable = original.isKeyTableNullable;
entityMappingType = delegate.entityMappingType; sqlAliasStem = original.sqlAliasStem;
referencedPropertyName = delegate.referencedPropertyName; targetKeyPropertyNames = original.targetKeyPropertyNames;
targetKeyPropertyName = delegate.targetKeyPropertyName; isNullable = original.isNullable;
cardinality = delegate.cardinality; foreignKeyDescriptor = original.foreignKeyDescriptor;
bidirectionalAttributePath = delegate.bidirectionalAttributePath; sideNature = original.sideNature;
declaringTableGroupProducer = delegate.declaringTableGroupProducer; identifyingColumnsTableExpression = original.identifyingColumnsTableExpression;
isKeyTableNullable = delegate.isKeyTableNullable; canUseParentTableGroup = original.canUseParentTableGroup;
sqlAliasStem = delegate.sqlAliasStem;
targetKeyPropertyNames = delegate.targetKeyPropertyNames;
isNullable = delegate.isNullable;
foreignKeyDescriptor = delegate.foreignKeyDescriptor;
} }
public ToOneAttributeMapping( public ToOneAttributeMapping(
@ -1186,7 +1183,7 @@ public class ToOneAttributeMapping
final FromClauseAccess fromClauseAccess = creationState.getSqlAstCreationState().getFromClauseAccess(); final FromClauseAccess fromClauseAccess = creationState.getSqlAstCreationState().getFromClauseAccess();
final TableGroup tableGroup = fromClauseAccess.getTableGroup( referencedNavigablePath ); final TableGroup tableGroup = fromClauseAccess.getTableGroup( referencedNavigablePath );
fromClauseAccess.registerTableGroup( fetchablePath, tableGroup ); fromClauseAccess.registerTableGroup( fetchablePath, tableGroup );
return new EntityFetchJoinedImpl( return buildEntityFetchJoined(
fetchParent, fetchParent,
this, this,
tableGroup, tableGroup,
@ -1216,7 +1213,7 @@ public class ToOneAttributeMapping
creationState creationState
); );
if ( fetchTiming == FetchTiming.IMMEDIATE ) { if ( fetchTiming == FetchTiming.IMMEDIATE ) {
return new EntityFetchSelectImpl( return buildEntityFetchSelect(
fetchParent, fetchParent,
this, this,
fetchablePath, fetchablePath,
@ -1226,7 +1223,7 @@ public class ToOneAttributeMapping
); );
} }
return new EntityDelayedFetchImpl( return buildEntityDelayedFetch(
fetchParent, fetchParent,
this, this,
fetchablePath, fetchablePath,
@ -1236,6 +1233,52 @@ public class ToOneAttributeMapping
} }
} }
// For Hibernate Reactive
protected EntityFetch buildEntityDelayedFetch(
FetchParent fetchParent,
ToOneAttributeMapping fetchedAttribute,
NavigablePath navigablePath,
DomainResult<?> keyResult,
boolean selectByUniqueKey) {
return new EntityDelayedFetchImpl( fetchParent, fetchedAttribute, navigablePath, keyResult, selectByUniqueKey );
}
// For Hibernate Reactive
protected EntityFetch buildEntityFetchSelect(
FetchParent fetchParent,
ToOneAttributeMapping fetchedAttribute,
NavigablePath navigablePath,
DomainResult<?> keyResult,
boolean selectByUniqueKey,
@SuppressWarnings("unused") DomainResultCreationState creationState) {
return new EntityFetchSelectImpl(
fetchParent,
fetchedAttribute,
navigablePath,
keyResult,
selectByUniqueKey,
creationState
);
}
// For Hibernate Reactive
protected EntityFetch buildEntityFetchJoined(
FetchParent fetchParent,
ToOneAttributeMapping toOneMapping,
TableGroup tableGroup,
DomainResult<?> keyResult,
NavigablePath navigablePath,
DomainResultCreationState creationState) {
return new EntityFetchJoinedImpl(
fetchParent,
toOneMapping,
tableGroup,
keyResult,
navigablePath,
creationState
);
}
private NavigablePath getReferencedNavigablePath( private NavigablePath getReferencedNavigablePath(
DomainResultCreationState creationState, DomainResultCreationState creationState,
NavigablePath parentNavigablePath) { NavigablePath parentNavigablePath) {
@ -1385,7 +1428,7 @@ public class ToOneAttributeMapping
); );
} }
return new EntityFetchJoinedImpl( return buildEntityFetchJoined(
fetchParent, fetchParent,
this, this,
tableGroup, tableGroup,
@ -1443,7 +1486,7 @@ public class ToOneAttributeMapping
// Consider all associations annotated with @NotFound as EAGER // Consider all associations annotated with @NotFound as EAGER
if ( fetchTiming == FetchTiming.IMMEDIATE || hasNotFoundAction() ) { if ( fetchTiming == FetchTiming.IMMEDIATE || hasNotFoundAction() ) {
return new EntityFetchSelectImpl( return buildEntityFetchSelect(
fetchParent, fetchParent,
this, this,
fetchablePath, fetchablePath,
@ -1453,7 +1496,7 @@ public class ToOneAttributeMapping
); );
} }
return new EntityDelayedFetchImpl( return buildEntityDelayedFetch(
fetchParent, fetchParent,
this, this,
fetchablePath, fetchablePath,

View File

@ -5420,7 +5420,7 @@ public abstract class AbstractEntityPersister
dependantValue = ( (DependantValue) bootProperty.getValue() ); dependantValue = ( (DependantValue) bootProperty.getValue() );
} }
return MappingModelCreationHelper.buildEmbeddedAttributeMapping( return buildEmbeddedAttributeMapping(
attrName, attrName,
stateArrayPosition, stateArrayPosition,
fetchableIndex, fetchableIndex,
@ -5437,7 +5437,7 @@ public abstract class AbstractEntityPersister
); );
} }
else if ( attrType instanceof CollectionType ) { else if ( attrType instanceof CollectionType ) {
return MappingModelCreationHelper.buildPluralAttributeMapping( return buildPluralAttributeMapping(
attrName, attrName,
stateArrayPosition, stateArrayPosition,
fetchableIndex, fetchableIndex,
@ -5450,7 +5450,7 @@ public abstract class AbstractEntityPersister
); );
} }
else if ( attrType instanceof EntityType ) { else if ( attrType instanceof EntityType ) {
return MappingModelCreationHelper.buildSingularAssociationAttributeMapping( return buildSingularAssociationAttributeMapping(
attrName, attrName,
getNavigableRole().append( attrName ), getNavigableRole().append( attrName ),
stateArrayPosition, stateArrayPosition,
@ -5470,6 +5470,90 @@ public abstract class AbstractEntityPersister
return null; return null;
} }
// For Hibernate Reactive
protected EmbeddedAttributeMapping buildEmbeddedAttributeMapping(
String attrName,
int stateArrayPosition,
int fetchableIndex,
Property bootProperty,
DependantValue dependantValue,
int dependantColumnIndex,
ManagedMappingType declaringType,
CompositeType attrType,
String tableExpression,
String[] rootTableKeyColumnNames,
PropertyAccess propertyAccess,
CascadeStyle cascadeStyle,
MappingModelCreationProcess creationProcess) {
return MappingModelCreationHelper.buildEmbeddedAttributeMapping(
attrName,
stateArrayPosition,
fetchableIndex,
bootProperty,
dependantValue,
dependantColumnIndex,
declaringType,
attrType,
tableExpression,
rootTableKeyColumnNames,
propertyAccess,
cascadeStyle,
creationProcess
);
}
// For Hibernate Reactive
protected AttributeMapping buildSingularAssociationAttributeMapping(
String attrName,
NavigableRole navigableRole,
int stateArrayPosition,
int fetchableIndex,
Property bootProperty,
ManagedMappingType declaringType,
EntityPersister declaringEntityPersister,
EntityType attrType,
PropertyAccess propertyAccess,
CascadeStyle cascadeStyle,
MappingModelCreationProcess creationProcess) {
return MappingModelCreationHelper.buildSingularAssociationAttributeMapping(
attrName,
navigableRole,
stateArrayPosition,
fetchableIndex,
bootProperty,
declaringType,
declaringEntityPersister,
attrType,
propertyAccess,
cascadeStyle,
creationProcess
);
}
// For Hibernate Reactive
protected AttributeMapping buildPluralAttributeMapping(
String attrName,
int stateArrayPosition,
int fetchableIndex,
Property bootProperty,
ManagedMappingType declaringType,
PropertyAccess propertyAccess,
CascadeStyle cascadeStyle,
FetchMode fetchMode,
MappingModelCreationProcess creationProcess) {
return MappingModelCreationHelper.buildPluralAttributeMapping(
attrName,
stateArrayPosition,
fetchableIndex,
bootProperty,
declaringType,
propertyAccess,
cascadeStyle,
fetchMode,
creationProcess
);
}
@Override @Override
public JavaType<?> getMappedJavaType() { public JavaType<?> getMappedJavaType() {
return javaType; return javaType;

View File

@ -6,6 +6,7 @@
*/ */
package org.hibernate.sql.results.graph.entity.internal; package org.hibernate.sql.results.graph.entity.internal;
import org.hibernate.LockMode;
import org.hibernate.annotations.NotFoundAction; import org.hibernate.annotations.NotFoundAction;
import org.hibernate.engine.FetchTiming; import org.hibernate.engine.FetchTiming;
import org.hibernate.metamodel.mapping.internal.EntityCollectionPart; import org.hibernate.metamodel.mapping.internal.EntityCollectionPart;
@ -15,10 +16,14 @@ import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.graph.AssemblerCreationState; import org.hibernate.sql.results.graph.AssemblerCreationState;
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.sql.results.graph.Fetch;
import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.graph.FetchParent;
import org.hibernate.sql.results.graph.FetchParentAccess; import org.hibernate.sql.results.graph.FetchParentAccess;
import org.hibernate.sql.results.graph.Initializer;
import org.hibernate.sql.results.graph.entity.AbstractNonLazyEntityFetch; import org.hibernate.sql.results.graph.entity.AbstractNonLazyEntityFetch;
import org.hibernate.sql.results.graph.entity.EntityInitializer; import org.hibernate.sql.results.graph.entity.EntityInitializer;
import org.hibernate.sql.results.graph.entity.EntityResultGraphNode;
import org.hibernate.sql.results.graph.entity.EntityValuedFetchable;
/** /**
* @author Andrea Boriero * @author Andrea Boriero
@ -74,6 +79,15 @@ public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch {
this.entityResult.afterInitialize( this, creationState ); this.entityResult.afterInitialize( this, creationState );
} }
// For Hibernate Reactive
protected EntityFetchJoinedImpl(EntityFetchJoinedImpl original ) {
super( original.getFetchParent(), original.getReferencedModePart(), original.getNavigablePath() );
this.entityResult = original.entityResult;
this.keyResult = original.keyResult;
this.notFoundAction = original.notFoundAction;
this.sourceAlias = original.sourceAlias;
}
@Override @Override
protected EntityInitializer getEntityInitializer( protected EntityInitializer getEntityInitializer(
FetchParentAccess parentAccess, FetchParentAccess parentAccess,
@ -81,7 +95,7 @@ public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch {
return creationState.resolveInitializer( return creationState.resolveInitializer(
getNavigablePath(), getNavigablePath(),
getReferencedModePart(), getReferencedModePart(),
() -> new EntityJoinedFetchInitializer( () -> buildEntityJoinedFetchInitializer(
entityResult, entityResult,
getReferencedModePart(), getReferencedModePart(),
getNavigablePath(), getNavigablePath(),
@ -95,6 +109,30 @@ public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch {
).asEntityInitializer(); ).asEntityInitializer();
} }
// For Hibernate Reactive
protected Initializer buildEntityJoinedFetchInitializer(
EntityResultGraphNode resultDescriptor,
EntityValuedFetchable referencedFetchable,
NavigablePath navigablePath,
LockMode lockMode,
NotFoundAction notFoundAction,
DomainResult<?> keyResult,
Fetch identifierFetch,
Fetch discriminatorFetch,
AssemblerCreationState creationState) {
return new EntityJoinedFetchInitializer(
resultDescriptor,
referencedFetchable,
navigablePath,
lockMode,
notFoundAction,
keyResult,
identifierFetch,
discriminatorFetch,
creationState
);
}
@Override @Override
public FetchTiming getTiming() { public FetchTiming getTiming() {
return FetchTiming.IMMEDIATE; return FetchTiming.IMMEDIATE;