Skip to content

Commit

Permalink
HHH-16120 Error advancing (next) ResultSet position
Browse files Browse the repository at this point in the history
  • Loading branch information
dreab8 authored and beikov committed Feb 6, 2023
1 parent f81426c commit ddfce2a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ else if ( !session.isConnected() ) {
Whenever the collection lazy loading is triggered during the loading process,
closing the connection will cause an error when RowProcessingStateStandardImpl#next() will be called.
*/
if ( !session.isTransactionInProgress() && session.getPersistenceContext().isLoadFinished() ) {
final PersistenceContext persistenceContext = session.getPersistenceContext();
if ( !session.isTransactionInProgress()
&& ( !persistenceContext.hasLoadContext()
|| ( persistenceContext.hasLoadContext()
&& persistenceContext.getLoadContexts().isLoadingFinished() ) ) ) {
session.getJdbcCoordinator().afterTransaction();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ public LoadContexts getLoadContexts() {
return loadContexts;
}

@Override
public boolean hasLoadContext() {
return loadContexts != null;
}

// @Override
// public void addUnownedCollection(CollectionKey key, PersistentCollection collection) {
// if ( unownedCollections == null ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public interface PersistenceContext {
*/
LoadContexts getLoadContexts();

default boolean hasLoadContext() {
getLoadContexts();
return true;
}

// /**
// * Add a collection which has no owner loaded
// *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public void deregister(JdbcValuesSourceProcessingState state) {
}
}

public boolean isLoadingFinished() {
return jdbcValuesSourceProcessingStateStack.depth() == 0;
}

public LoadingEntityEntry findLoadingEntityEntry(EntityKey entityKey) {
return jdbcValuesSourceProcessingStateStack.findCurrentFirst(
state -> state.findLoadingEntityLocally( entityKey )
Expand Down

0 comments on commit ddfce2a

Please sign in to comment.