HHH-16672 Locking entities created in the same transaction fails

This commit is contained in:
Andrea Boriero 2024-03-05 12:48:45 +01:00 committed by Andrea Boriero
parent aba5ac47a0
commit 5eacb26f09
1 changed files with 6 additions and 1 deletions

View File

@ -107,8 +107,13 @@ public class LoaderHelper {
entry.forceLocked( object, nextVersion ); entry.forceLocked( object, nextVersion );
} }
else { else {
if ( entry.isExistsInDatabase() ) {
persister.lock( entry.getId(), entry.getVersion(), object, lockOptions, session ); persister.lock( entry.getId(), entry.getVersion(), object, lockOptions, session );
} }
else {
session.forceFlush( entry );
}
}
entry.setLockMode(requestedLockMode); entry.setLockMode(requestedLockMode);
} }
finally { finally {