HHH-15695 Batch loading, Embeddable with an Association is considered null when all the other Embeddable attributes are null

This commit is contained in:
Andrea Boriero 2022-11-09 18:47:09 +01:00 committed by Andrea Boriero
parent 7f7e54c42d
commit 4688cccdbc
19 changed files with 103 additions and 186 deletions

View File

@ -53,7 +53,7 @@ public class FetchingScrollableResultsImpl<R> extends AbstractScrollableResults<
private static <R> EntityInitializer extractResultInitializer(RowReader<R> rowReader) {
Initializer initializer = rowReader.getInitializers().get( rowReader.getInitializers().size() - 1 );
if ( initializer instanceof EntityInitializer ) {
if ( initializer.isEntityInitializer() ) {
return (EntityInitializer) initializer;
}
return null;

View File

@ -24,7 +24,7 @@ public interface FetchParentAccess extends Initializer {
FetchParentAccess findFirstEntityDescriptorAccess();
default EntityInitializer findFirstEntityInitializer(){
if ( this instanceof EntityInitializer ) {
if ( this.isEntityInitializer() ) {
return (EntityInitializer) this;
}
return (EntityInitializer) findFirstEntityDescriptorAccess();
@ -40,8 +40,4 @@ public interface FetchParentAccess extends Initializer {
* @apiNote If already resolved, the callback is triggered immediately
*/
void registerResolutionListener(Consumer<Object> resolvedParentConsumer);
default boolean isEmbeddable(){
return false;
}
}

View File

@ -7,6 +7,8 @@
package org.hibernate.sql.results.graph;
import org.hibernate.Incubating;
import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.spi.NavigablePath;
@ -70,4 +72,35 @@ public interface Initializer {
default void endLoading(ExecutionContext context) {
// by default - nothing to do
}
default boolean isAttributeAssignableToConcreteDescriptor(
FetchParentAccess parentAccess,
AttributeMapping referencedModelPart) {
if ( parentAccess != null && parentAccess.isEntityInitializer() ) {
final EntityPersister concreteDescriptor = parentAccess.findFirstEntityInitializer()
.getConcreteDescriptor();
if ( concreteDescriptor.getEntityMetamodel().isPolymorphic() ) {
final EntityPersister declaringType = (EntityPersister) referencedModelPart.getDeclaringType();
if ( concreteDescriptor != declaringType ) {
if ( !declaringType.getSubclassEntityNames().contains( concreteDescriptor.getEntityName() ) ) {
return false;
}
}
}
}
return true;
}
default boolean isEmbeddableInitializer(){
return false;
}
default boolean isEntityInitializer(){
return false;
}
default boolean isCollectionInitializer(){
return false;
}
}

View File

@ -41,5 +41,10 @@ public interface CollectionInitializer extends Initializer {
// by default - nothing to do
}
@Override
default boolean isCollectionInitializer() {
return true;
}
CollectionKey resolveCollectionKey(RowProcessingState rowProcessingState);
}

View File

@ -15,14 +15,12 @@ import org.hibernate.internal.log.LoggingHelper;
import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.graph.FetchParentAccess;
import org.hibernate.sql.results.graph.collection.CollectionInitializer;
import org.hibernate.sql.results.graph.collection.CollectionLoadingLogger;
import org.hibernate.sql.results.graph.collection.LoadingCollectionEntry;
import org.hibernate.sql.results.graph.entity.EntityInitializer;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
/**
@ -62,7 +60,7 @@ public abstract class AbstractCollectionInitializer implements CollectionInitial
return;
}
if ( !isAttributeAssignableToConcreteDescriptor() ) {
if ( !isAttributeAssignableToConcreteDescriptor( parentAccess, collectionAttributeMapping ) ) {
return;
}
@ -151,21 +149,6 @@ public abstract class AbstractCollectionInitializer implements CollectionInitial
}
}
protected boolean isAttributeAssignableToConcreteDescriptor() {
if ( parentAccess instanceof EntityInitializer ) {
final AbstractEntityPersister concreteDescriptor = (AbstractEntityPersister) ( (EntityInitializer) parentAccess ).getConcreteDescriptor();
if ( concreteDescriptor.isPolymorphic() ) {
final AbstractEntityPersister declaringType = (AbstractEntityPersister) collectionAttributeMapping.getDeclaringType();
if ( concreteDescriptor != declaringType ) {
if ( !declaringType.getSubclassEntityNames().contains( concreteDescriptor.getName() ) ) {
return false;
}
}
}
}
return true;
}
@Override
public PersistentCollection<?> getCollectionInstance() {
return collectionInstance;

View File

@ -7,7 +7,6 @@
package org.hibernate.sql.results.graph.embeddable;
import java.util.List;
import java.util.function.Supplier;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -41,6 +40,7 @@ import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;
import static org.hibernate.internal.util.collections.CollectionHelper.arrayList;
import static org.hibernate.sql.results.graph.entity.internal.BatchEntityInsideEmbeddableSelectFetchInitializer.BATCH_PROPERTY;
/**
* @author Steve Ebersole
@ -268,7 +268,12 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
processingState.getJdbcValuesSourceProcessingState().getProcessingOptions()
);
rowState[i] = contributorValue;
if ( contributorValue == BATCH_PROPERTY ) {
rowState[i] = null;
}
else {
rowState[i] = contributorValue;
}
if ( contributorValue != null ) {
stateAllNull = false;
}
@ -323,9 +328,6 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
return NULL_MARKER;
}
final Supplier<Object[]> valuesAccess = stateAllNull == TRUE
? null
: () -> rowState;
final Object instance = representationStrategy.getInstantiator().instantiate( this, sessionFactory );
stateInjected = true;
@ -419,11 +421,11 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA
final Initializer parentInitializer = processingState.resolveInitializer( parentPath );
if ( parentInitializer instanceof CollectionInitializer ) {
if ( parentInitializer.isCollectionInitializer() ) {
return ( (CollectionInitializer) parentInitializer ).getCollectionInstance().getOwner();
}
if ( parentInitializer instanceof EntityInitializer ) {
if ( parentInitializer.isEntityInitializer() ) {
return ( (EntityInitializer) parentInitializer ).getEntityInstance();
}

View File

@ -27,7 +27,7 @@ public interface EmbeddableInitializer extends FetchParentAccess {
}
@Override
default boolean isEmbeddable() {
default boolean isEmbeddableInitializer() {
return true;
}
}

View File

@ -49,4 +49,9 @@ public interface EntityInitializer extends FetchParentAccess {
}
EntityKey getEntityKey();
@Override
default boolean isEntityInitializer() {
return true;
}
}

View File

@ -8,26 +8,18 @@ package org.hibernate.sql.results.graph.entity.internal;
import java.util.function.Consumer;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.results.graph.AbstractFetchParentAccess;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.graph.FetchParentAccess;
import org.hibernate.sql.results.graph.Initializer;
import org.hibernate.sql.results.graph.entity.EntityInitializer;
import org.hibernate.sql.results.graph.entity.EntityLoadingLogging;
import org.hibernate.sql.results.graph.entity.LoadingEntityEntry;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
import static org.hibernate.internal.log.LoggingHelper.toLoggableString;
public abstract class AbstractBatchEntitySelectFetchInitializer extends AbstractFetchParentAccess
implements EntityInitializer {
@ -41,9 +33,6 @@ public abstract class AbstractBatchEntitySelectFetchInitializer extends Abstract
protected Object entityInstance;
protected EntityKey entityKey;
private boolean isInitialized;
public AbstractBatchEntitySelectFetchInitializer(
FetchParentAccess parentAccess,
ToOneAttributeMapping referencedModelPart,
@ -68,106 +57,30 @@ public abstract class AbstractBatchEntitySelectFetchInitializer extends Abstract
@Override
public void resolveKey(RowProcessingState rowProcessingState) {
}
@Override
public void resolveInstance(RowProcessingState rowProcessingState) {
}
@Override
public void initializeInstance(RowProcessingState rowProcessingState) {
if ( isInitialized ) {
return;
}
if ( !isAttributeAssignableToConcreteDescriptor() ) {
return;
}
final Object entityIdentifier = identifierAssembler.assemble( rowProcessingState );
if ( entityIdentifier == null ) {
return;
}
entityKey = new EntityKey( entityIdentifier, concreteDescriptor );
final PersistenceContext persistenceContext = rowProcessingState.getSession().getPersistenceContextInternal();
entityInstance = persistenceContext.getEntity( entityKey );
if ( entityInstance != null ) {
return;
}
Initializer initializer = rowProcessingState.getJdbcValuesSourceProcessingState()
.findInitializer( entityKey );
if ( initializer != null ) {
if ( EntityLoadingLogging.DEBUG_ENABLED ) {
EntityLoadingLogging.ENTITY_LOADING_LOGGER.debugf(
"(%s) Found an initializer for entity (%s) : %s",
getConcreteName(),
toLoggableString( getNavigablePath(), entityIdentifier ),
entityIdentifier
);
}
initializer.resolveInstance( rowProcessingState );
entityInstance = initializer.getInitializedInstance();
// EARLY EXIT!!!
return;
}
final LoadingEntityEntry existingLoadingEntry = rowProcessingState.getSession()
.getPersistenceContext()
.getLoadContexts()
.findLoadingEntityEntry( entityKey );
if ( existingLoadingEntry != null ) {
if ( existingLoadingEntry.getEntityInitializer() != this ) {
// the entity is already being loaded elsewhere
if ( EntityLoadingLogging.DEBUG_ENABLED ) {
EntityLoadingLogging.ENTITY_LOADING_LOGGER.debugf(
"(%s) Entity [%s] being loaded by another initializer [%s] - skipping processing",
getConcreteName(),
toLoggableString( getNavigablePath(), entityIdentifier ),
existingLoadingEntry.getEntityInitializer()
);
}
this.entityInstance = existingLoadingEntry.getEntityInstance();
// EARLY EXIT!!!
return;
}
}
persistenceContext.getBatchFetchQueue().addBatchLoadableEntityKey( entityKey );
addParentInfo();
isInitialized = true;
rowProcessingState.getSession().getPersistenceContext()
.getBatchFetchQueue().addBatchLoadableEntityKey( entityKey );
}
protected abstract String getConcreteName();
@Override
public void resolveInstance(RowProcessingState rowProcessingState) {
}
@Override
public void initializeInstance(RowProcessingState rowProcessingState) {
}
protected abstract void addParentInfo();
protected boolean isAttributeAssignableToConcreteDescriptor() {
if ( parentAccess instanceof EntityInitializer ) {
final AbstractEntityPersister concreteDescriptor = (AbstractEntityPersister) ( (EntityInitializer) parentAccess ).getConcreteDescriptor();
if ( concreteDescriptor.isPolymorphic() ) {
final AbstractEntityPersister declaringType = (AbstractEntityPersister) referencedModelPart.getDeclaringType();
if ( concreteDescriptor != declaringType ) {
if ( !declaringType.getSubclassEntityNames().contains( concreteDescriptor.getName() ) ) {
return false;
}
}
}
}
return true;
}
@Override
public void finishUpRow(RowProcessingState rowProcessingState) {
entityInstance = null;
clearResolutionListeners();
isInitialized = false;
}
@Override
@ -187,7 +100,7 @@ public abstract class AbstractBatchEntitySelectFetchInitializer extends Abstract
@Override
public Object getParentKey() {
throw new NotYetImplementedFor6Exception( getClass() );
return findFirstEntityInitializer().getEntityKey().getIdentifier();
}
@Override

View File

@ -6,6 +6,7 @@
*/
package org.hibernate.sql.results.graph.entity.internal;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -23,14 +24,28 @@ import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.graph.FetchParentAccess;
import org.hibernate.sql.results.graph.entity.EntityInitializer;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
public class BatchEntityInsideEmbeddableSelectFetchInitializer extends AbstractBatchEntitySelectFetchInitializer {
private static final String CONCRETE_NAME = BatchEntityInsideEmbeddableSelectFetchInitializer.class.getSimpleName();
/*
Object[0] will contain the parent EntityKey and Object[1] the parent embeddable instance,
*/
private Map<EntityKey, List<Object[]>> toBatchLoad = new HashMap<>();
private final Map<EntityKey, List<Object[]>> toBatchLoad = new HashMap<>();
/**
* Marker value for batch properties, needed by the EmbeddableInitializer to instantiate the
* embeddable instance in case all the other properties are null.
*/
public static final Serializable BATCH_PROPERTY = new Serializable() {
@Override
public String toString() {
return "<batch>";
}
public Object readResolve() {
return BATCH_PROPERTY;
}
};
public BatchEntityInsideEmbeddableSelectFetchInitializer(
FetchParentAccess parentAccess,
@ -42,8 +57,12 @@ public class BatchEntityInsideEmbeddableSelectFetchInitializer extends AbstractB
}
@Override
protected String getConcreteName() {
return CONCRETE_NAME;
public void resolveInstance(RowProcessingState rowProcessingState) {
if ( entityKey == null ) {
return;
}
entityInstance = BATCH_PROPERTY;
}
@Override

View File

@ -24,8 +24,6 @@ import org.hibernate.sql.results.graph.FetchParentAccess;
import org.hibernate.sql.results.graph.entity.EntityInitializer;
public class BatchEntitySelectFetchInitializer extends AbstractBatchEntitySelectFetchInitializer {
private static final String CONCRETE_NAME = BatchEntitySelectFetchInitializer.class.getSimpleName();
private final Map<EntityKey, List<Object>> toBatchLoad = new HashMap<>();
public BatchEntitySelectFetchInitializer(
@ -37,11 +35,6 @@ public class BatchEntitySelectFetchInitializer extends AbstractBatchEntitySelect
super( parentAccess, referencedModelPart, fetchedNavigable, concreteDescriptor, identifierAssembler );
}
@Override
protected String getConcreteName() {
return CONCRETE_NAME;
}
@Override
protected void addParentInfo() {
final List<Object> parents = getBatchInfos();

View File

@ -18,7 +18,6 @@ import org.hibernate.type.descriptor.java.JavaType;
public class EntityAssembler implements DomainResultAssembler {
private final JavaType javaType;
private final EntityInitializer initializer;
private EntityInitializer replacedInitializer;
public EntityAssembler(
JavaType javaType,

View File

@ -16,7 +16,6 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.log.LoggingHelper;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.UniqueKeyLoadable;
import org.hibernate.proxy.HibernateProxy;
@ -82,7 +81,7 @@ public class EntityDelayedFetchInitializer extends AbstractFetchParentAccess imp
return;
}
if ( !isAttributeAssignableToConcreteDescriptor() ) {
if ( !isAttributeAssignableToConcreteDescriptor( parentAccess, referencedModelPart ) ) {
return;
}
@ -174,21 +173,6 @@ public class EntityDelayedFetchInitializer extends AbstractFetchParentAccess imp
}
}
protected boolean isAttributeAssignableToConcreteDescriptor() {
if ( parentAccess instanceof EntityInitializer ) {
final AbstractEntityPersister concreteDescriptor = (AbstractEntityPersister) ( (EntityInitializer) parentAccess ).getConcreteDescriptor();
if ( concreteDescriptor.isPolymorphic() ) {
final AbstractEntityPersister declaringType = (AbstractEntityPersister) referencedModelPart.getDeclaringType();
if ( concreteDescriptor != declaringType ) {
if ( !declaringType.getSubclassEntityNames().contains( concreteDescriptor.getName() ) ) {
return false;
}
}
}
}
return true;
}
@Override
public void initializeInstance(RowProcessingState rowProcessingState) {
// nothing to do

View File

@ -70,7 +70,7 @@ public class EntityFetchSelectImpl extends AbstractNonJoinedEntityFetch {
);
}
if ( entityPersister.isBatchLoadable() && !creationState.isScrollResult() ) {
if ( parentAccess.isEmbeddable() ) {
if ( parentAccess.isEmbeddableInitializer() ) {
return new BatchEntityInsideEmbeddableSelectFetchInitializer(
parentAccess,
fetchedAttribute,

View File

@ -18,7 +18,6 @@ import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.spi.NavigablePath;
@ -224,18 +223,7 @@ public class EntitySelectFetchInitializer extends AbstractFetchParentAccess impl
}
protected boolean isAttributeAssignableToConcreteDescriptor() {
if ( parentAccess instanceof EntityInitializer ) {
final AbstractEntityPersister concreteDescriptor = (AbstractEntityPersister) ( (EntityInitializer) parentAccess ).getConcreteDescriptor();
if ( concreteDescriptor.isPolymorphic() ) {
final AbstractEntityPersister declaringType = (AbstractEntityPersister) toOneMapping.getDeclaringType();
if ( concreteDescriptor != declaringType ) {
if ( !declaringType.getSubclassEntityNames().contains( concreteDescriptor.getName() ) ) {
return false;
}
}
}
}
return true;
return isAttributeAssignableToConcreteDescriptor( parentAccess, toOneMapping );
}
@Override

View File

@ -16,7 +16,6 @@ import org.hibernate.query.spi.QueryParameterBindings;
import org.hibernate.sql.exec.spi.Callback;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.results.graph.Initializer;
import org.hibernate.sql.results.graph.collection.CollectionInitializer;
import org.hibernate.sql.results.graph.entity.EntityFetch;
import org.hibernate.sql.results.jdbc.internal.JdbcValuesCacheHit;
import org.hibernate.sql.results.jdbc.internal.JdbcValuesSourceProcessingStateStandardImpl;
@ -64,7 +63,7 @@ public class RowProcessingStateStandardImpl implements RowProcessingState {
private static boolean hasCollectionInitializers(Initializer[] initializers) {
for ( int i = 0; i < initializers.length; i++ ) {
if ( initializers[i] instanceof CollectionInitializer ) {
if ( initializers[i].isCollectionInitializer() ) {
return true;
}
}

View File

@ -15,7 +15,6 @@ import org.hibernate.query.named.RowReaderMemento;
import org.hibernate.sql.results.LoadingLogger;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.graph.Initializer;
import org.hibernate.sql.results.graph.collection.CollectionInitializer;
import org.hibernate.sql.results.graph.entity.internal.EntityDelayedFetchInitializer;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState;
@ -123,14 +122,14 @@ public class StandardRowReader<T> implements RowReader<T> {
for ( int i = 0; i < numberOfInitializers; i++ ) {
final Initializer initializer = initializers.get( i );
if ( ! ( initializer instanceof CollectionInitializer ) ) {
if ( ! initializer.isCollectionInitializer() ) {
initializer.resolveKey( rowProcessingState );
}
}
for ( int i = 0; i < numberOfInitializers; i++ ) {
final Initializer initializer = initializers.get( i );
if ( initializer instanceof CollectionInitializer ) {
if ( initializer.isCollectionInitializer() ) {
initializer.resolveKey( rowProcessingState );
}
}

View File

@ -237,7 +237,7 @@ public class CircularBiDirectionalFetchImpl implements BiDirectionalFetch, Assoc
if ( circularPath.getParent() != null ) {
NavigablePath path = circularPath.getParent();
Initializer parentInitializer = rowProcessingState.resolveInitializer( path );
while ( !( parentInitializer instanceof EntityInitializer ) && path.getParent() != null ) {
while ( !parentInitializer.isEntityInitializer() && path.getParent() != null ) {
path = path.getParent();
parentInitializer = rowProcessingState.resolveInitializer( path );
}
@ -245,7 +245,7 @@ public class CircularBiDirectionalFetchImpl implements BiDirectionalFetch, Assoc
}
else {
final Initializer parentInitializer = rowProcessingState.resolveInitializer( circularPath );
assert parentInitializer instanceof CollectionInitializer;
assert parentInitializer.isCollectionInitializer();
final CollectionInitializer circ = (CollectionInitializer) parentInitializer;
final EntityPersister entityPersister = (EntityPersister) ( (AttributeMapping) fetchable ).getMappedType();
final CollectionKey collectionKey = circ.resolveCollectionKey( rowProcessingState );
@ -317,10 +317,10 @@ public class CircularBiDirectionalFetchImpl implements BiDirectionalFetch, Assoc
private EntityInitializer resolveCircularInitializer(RowProcessingState rowProcessingState) {
final Initializer initializer = rowProcessingState.resolveInitializer( circularPath );
if ( initializer instanceof EntityInitializer ) {
if ( initializer.isEntityInitializer() ) {
return (EntityInitializer) initializer;
}
if ( initializer instanceof CollectionInitializer ) {
if ( initializer.isCollectionInitializer() ) {
return null;
}
final ModelPart initializedPart = initializer.getInitializedPart();
@ -331,12 +331,12 @@ public class CircularBiDirectionalFetchImpl implements BiDirectionalFetch, Assoc
NavigablePath path = circularPath.getParent();
Initializer parentInitializer = rowProcessingState.resolveInitializer( path );
while ( !( parentInitializer instanceof EntityInitializer ) && path.getParent() != null ) {
while ( !parentInitializer.isEntityInitializer() && path.getParent() != null ) {
path = path.getParent();
parentInitializer = rowProcessingState.resolveInitializer( path );
}
if ( !( parentInitializer instanceof EntityInitializer ) ) {
if ( !parentInitializer.isEntityInitializer() ) {
return null;
}

View File

@ -13,7 +13,6 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.mapping.IndexedConsumer;
import org.hibernate.metamodel.mapping.Association;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.EntityValuedModelPart;
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.MappingType;
@ -128,7 +127,7 @@ public class CircularFetchImpl implements BiDirectionalFetch, Association {
}
final EntityPersister entityPersister = entityMappingType.getEntityPersister();
if ( entityPersister.isBatchLoadable() ) {
if ( parentAccess.isEmbeddable() ) {
if ( parentAccess.isEmbeddableInitializer() ) {
return new BatchEntityInsideEmbeddableSelectFetchInitializer(
parentAccess,
referencedModelPart,