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 ca2ae23f78
commit c6a9278599
1 changed files with 6 additions and 1 deletions

View File

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