mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-07 19:58:16 +00:00
HHH-12268 : LazyInitializationException thrown from lazy collection when batch fetching enabled and owning entity refreshed with lock
(cherry picked from commit 06c78087ff66f6d2f24408169da5510f2e88a549)
This commit is contained in:
parent
f13cdcf2c9
commit
b4b5a6f379
@ -200,6 +200,9 @@ public final List loadEntityBatch(
|
||||
final QueryParameters qp = new QueryParameters();
|
||||
qp.setPositionalParameterTypes( types );
|
||||
qp.setPositionalParameterValues( ids );
|
||||
qp.setOptionalObject( optionalObject );
|
||||
qp.setOptionalEntityName( optionalEntityName );
|
||||
qp.setOptionalId( optionalId );
|
||||
qp.setLockOptions( lockOptions );
|
||||
if ( readOnly != null ) {
|
||||
qp.setReadOnly( readOnly );
|
||||
|
@ -16,12 +16,10 @@
|
||||
|
||||
import org.hibernate.engine.internal.TwoPhaseLoad;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
import org.hibernate.event.spi.EventType;
|
||||
import org.hibernate.event.spi.PostLoadEvent;
|
||||
import org.hibernate.event.spi.PostLoadEventListener;
|
||||
import org.hibernate.event.spi.PreLoadEvent;
|
||||
import org.hibernate.event.spi.PreLoadEventListener;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
|
@ -232,9 +232,9 @@ public void hydrateEntityState(ResultSet resultSet, ResultSetProcessingContextIm
|
||||
|
||||
// determine which entity instance to use. Either the supplied one, or instantiate one
|
||||
Object entityInstance = null;
|
||||
if ( isReturn &&
|
||||
context.shouldUseOptionalEntityInformation() &&
|
||||
context.getQueryParameters().getOptionalObject() != null ) {
|
||||
// If an "optional" instance with an EntityKey equal to entityKey is available
|
||||
// in the context, then use that instance.
|
||||
if ( isReturn && context.getQueryParameters().getOptionalObject() != null ) {
|
||||
final EntityKey optionalEntityKey = ResultSetProcessorHelper.getOptionalObjectKey(
|
||||
context.getQueryParameters(),
|
||||
context.getSession()
|
||||
|
Loading…
x
Reference in New Issue
Block a user