HHH-16820 When batching enabled the LockModeType is ignored

This commit is contained in:
Andrea Boriero 2023-06-22 10:55:06 +02:00 committed by Andrea Boriero
parent bbbf8e969b
commit bdcc619e29
1 changed files with 3 additions and 1 deletions

View File

@ -7,6 +7,7 @@
package org.hibernate.loader.ast.internal;
import org.hibernate.Hibernate;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.SessionFactoryImplementor;
@ -89,7 +90,8 @@ public abstract class AbstractEntityBatchLoader<T>
LockOptions lockOptions,
Boolean readOnly,
SharedSessionContractImplementor session) {
if ( hasSingleId ) {
// We disable batching if lockMode != NONE
if ( hasSingleId || lockOptions.getLockMode() != LockMode.NONE ) {
return singleIdLoader.load( id, entityInstance, lockOptions, readOnly, session );
}