HHH-17173 Getting one-to-one association through a referenece to a bytecode enchanced entity fails

This commit is contained in:
Andrea Boriero 2023-09-07 12:24:34 +02:00 committed by Andrea Boriero
parent a1f6ee2378
commit 86d1f278bc
1 changed files with 11 additions and 1 deletions

View File

@ -98,7 +98,6 @@ public abstract class AbstractBatchEntitySelectFetchInitializer extends Abstract
else {
entityKey = new EntityKey( entityIdentifier, concreteDescriptor );
state = State.KEY_RESOLVED;
registerResolutionListener();
}
}
@ -117,6 +116,17 @@ public abstract class AbstractBatchEntitySelectFetchInitializer extends Abstract
else if ( isInitialized( instance ) ) {
return instance;
}
else {
// the instance is not initialized but there is another initialzier that is loading it
final LoadingEntityEntry loadingEntityEntry = persistenceContext
.getLoadContexts().findLoadingEntityEntry( entityKey );
if ( loadingEntityEntry != null ) {
return loadingEntityEntry.getEntityInstance();
}
}
// we need to register a resolution listener only if there is not an already initialized instance
// or an instance that another initialzier is loading
registerResolutionListener();
return null;
}