HHH-16740 Fetching an element collection on an entity with a composite id fails when batch size > 1
This commit is contained in:
parent
c44086778a
commit
3e8cfeb659
|
@ -24,7 +24,7 @@ import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
|
|||
public abstract class AbstractBatchEntitySelectFetchInitializer extends AbstractFetchParentAccess
|
||||
implements EntityInitializer {
|
||||
|
||||
protected FetchParentAccess parentAccess;
|
||||
protected final FetchParentAccess parentAccess;
|
||||
private final NavigablePath navigablePath;
|
||||
|
||||
protected final EntityPersister concreteDescriptor;
|
||||
|
@ -47,6 +47,7 @@ public abstract class AbstractBatchEntitySelectFetchInitializer extends Abstract
|
|||
this.concreteDescriptor = concreteDescriptor;
|
||||
this.identifierAssembler = identifierAssembler;
|
||||
this.firstEntityInitializer = parentAccess.findFirstEntityInitializer();
|
||||
assert firstEntityInitializer != null : "This initializer requires parentAccess.findFirstEntityInitializer() to not be null";
|
||||
}
|
||||
|
||||
public ModelPart getInitializedPart() {
|
||||
|
|
|
@ -133,7 +133,6 @@ public class BatchEntityInsideEmbeddableSelectFetchInitializer extends AbstractB
|
|||
);
|
||||
toBatchLoad.clear();
|
||||
}
|
||||
parentAccess = null;
|
||||
}
|
||||
|
||||
protected static void setInstance(
|
||||
|
|
|
@ -92,7 +92,6 @@ public class BatchEntitySelectFetchInitializer extends AbstractBatchEntitySelect
|
|||
);
|
||||
toBatchLoad.clear();
|
||||
}
|
||||
parentAccess = null;
|
||||
}
|
||||
|
||||
protected static void setInstance(
|
||||
|
|
|
@ -100,7 +100,6 @@ public class BatchInitializeEntitySelectFetchInitializer extends AbstractBatchEn
|
|||
loadInstance( key, referencedModelPart, session );
|
||||
}
|
||||
toBatchLoad.clear();
|
||||
parentAccess = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,6 +38,16 @@ public class EntitySelectFetchInitializerBuilder {
|
|||
keyResult.createResultAssembler( parentAccess, creationState )
|
||||
);
|
||||
}
|
||||
if ( parentAccess.findFirstEntityInitializer() == null ) {
|
||||
// Batch initializers require parentAccess.findFirstEntityInitializer() != null
|
||||
return new EntitySelectFetchInitializer(
|
||||
parentAccess,
|
||||
fetchedAttribute,
|
||||
navigablePath,
|
||||
entityPersister,
|
||||
keyResult.createResultAssembler( parentAccess, creationState )
|
||||
);
|
||||
}
|
||||
final BatchMode batchMode = determineBatchMode( entityPersister, parentAccess, creationState );
|
||||
switch ( batchMode ) {
|
||||
case NONE:
|
||||
|
|
Loading…
Reference in New Issue