HHH-15449 @ManyToOne associations not loaded correctly with default EAGER and batch fetch property set when using TypedQuery.resultStream

This commit is contained in:
Andrea Boriero 2022-08-17 16:50:08 +02:00 committed by Andrea Boriero
parent 960b2c7f1c
commit 021429b519
5 changed files with 21 additions and 1 deletions

View File

@ -228,6 +228,12 @@ public class JdbcSelectExecutorStandardImpl implements JdbcSelectExecutor {
final Limit limit = queryOptions.getLimit();
return new ExecutionContext() {
@Override
public boolean isScrollResult() {
return true;
}
@Override
public QueryOptions getQueryOptions() {

View File

@ -21,6 +21,10 @@ import org.hibernate.sql.results.graph.entity.LoadingEntityEntry;
*/
public interface ExecutionContext {
default boolean isScrollResult(){
return false;
}
SharedSessionContractImplementor getSession();
QueryOptions getQueryOptions();

View File

@ -18,6 +18,10 @@ import org.hibernate.sql.ast.spi.SqlAstCreationContext;
*/
public interface AssemblerCreationState {
default boolean isScrollResult() {
return false;
}
LockMode determineEffectiveLockMode(String identificationVariable);
Initializer resolveInitializer(

View File

@ -69,7 +69,7 @@ public class EntityFetchSelectImpl extends AbstractNonJoinedEntityFetch {
keyResult.createResultAssembler( parentAccess, creationState )
);
}
if ( entityPersister.isBatchLoadable() ) {
if ( entityPersister.isBatchLoadable() && !creationState.isScrollResult() ) {
return new BatchEntitySelectFetchInitializer(
parentAccess,
fetchedAttribute,

View File

@ -66,6 +66,12 @@ public class ResultsHelper {
final List<DomainResultAssembler<?>> assemblers = jdbcValues.getValuesMapping().resolveAssemblers(
new AssemblerCreationState() {
@Override
public boolean isScrollResult() {
return executionContext.isScrollResult();
}
@Override
public LockMode determineEffectiveLockMode(String identificationVariable) {
return lockOptions.getEffectiveLockMode( identificationVariable );