Skip to content

Commit

Permalink
HHH-15449 @manytoone associations not loaded correctly with default E…
Browse files Browse the repository at this point in the history
…AGER and batch fetch property set when using TypedQuery.resultStream
  • Loading branch information
dreab8 committed Aug 24, 2022
1 parent 960b2c7 commit 021429b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ private ExecutionContext getScrollContext(ExecutionContext context, PersistenceC
final Limit limit = queryOptions.getLimit();

return new ExecutionContext() {

@Override
public boolean isScrollResult() {
return true;
}

@Override
public QueryOptions getQueryOptions() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
*/
public interface ExecutionContext {

default boolean isScrollResult(){
return false;
}

SharedSessionContractImplementor getSession();

QueryOptions getQueryOptions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
*/
public interface AssemblerCreationState {

default boolean isScrollResult() {
return false;
}

LockMode determineEffectiveLockMode(String identificationVariable);

Initializer resolveInitializer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public DomainResultAssembler<?> createAssembler(FetchParentAccess parentAccess,
keyResult.createResultAssembler( parentAccess, creationState )
);
}
if ( entityPersister.isBatchLoadable() ) {
if ( entityPersister.isBatchLoadable() && !creationState.isScrollResult() ) {
return new BatchEntitySelectFetchInitializer(
parentAccess,
fetchedAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public static <R> RowReader<R> createRowReader(

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 );
Expand Down

0 comments on commit 021429b

Please sign in to comment.