HHH-16106 Using BatchEntitySelectFetchInitializer causes PostLoad to be called before references are initialized

This commit is contained in:
Andrea Boriero 2023-01-26 14:19:23 +01:00 committed by Andrea Boriero
parent 10458da711
commit 6c385f7890
2 changed files with 2 additions and 24 deletions

View File

@ -163,13 +163,6 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo
@Override
public void finishUp() {
// for arrays, we should end the collection load beforeQuery resolving the entities, since the
// actual array instances are not instantiated during loading
finishLoadingArrays();
// now finish loading the entities (2-phase load)
performTwoPhaseLoad();
// now we can finalize loading collections
finishLoadingCollections();
@ -207,22 +200,6 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo
loadingEntityMap = null;
}
private void finishLoadingArrays() {
if ( arrayInitializers != null ) {
for ( CollectionInitializer collectionInitializer : arrayInitializers ) {
collectionInitializer.endLoading( executionContext );
}
}
}
private void performTwoPhaseLoad() {
if ( loadingEntityMap == null ) {
return;
}
log.tracev( "Total objects hydrated: {0}", loadingEntityMap.size() );
}
@SuppressWarnings("SimplifiableIfStatement")
private boolean isReadOnly() {
if ( getQueryOptions().isReadOnly() != null ) {

View File

@ -201,6 +201,7 @@ public class ListResultsConsumer<R> implements ResultsConsumer<List<R>, R> {
}
try {
rowReader.finishUp( jdbcValuesSourceProcessingState );
jdbcValuesSourceProcessingState.finishUp();
}
finally {
@ -220,7 +221,7 @@ public class ListResultsConsumer<R> implements ResultsConsumer<List<R>, R> {
}
finally {
try {
rowReader.finishUp( jdbcValuesSourceProcessingState );
jdbcValues.finishUp( session );
persistenceContext.initializeNonLazyCollections();
}