HHH-18032 CompositeId, when the id assigned by PrePersist method an HibernateException: identifier of an instance of _ was altered is thrown

This commit is contained in:
Andrea Boriero 2024-05-02 13:24:55 +02:00 committed by Christian Beikov
parent 2af8e2024c
commit 82c2186363
1 changed files with 3 additions and 1 deletions

View File

@ -26,6 +26,7 @@ import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.Status;
import org.hibernate.event.spi.EventSource;
import org.hibernate.id.Assigned;
import org.hibernate.id.CompositeNestedGeneratedValueGenerator;
import org.hibernate.id.IdentifierGenerationException;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
@ -197,7 +198,8 @@ public abstract class AbstractSaveEventListener<C>
processIfSelfDirtinessTracker( entity, SelfDirtinessTracker::$$_hibernate_clearDirtyAttributes );
if ( persister.getGenerator() instanceof Assigned ) {
final Generator generator = persister.getGenerator();
if ( generator instanceof Assigned || generator instanceof CompositeNestedGeneratedValueGenerator ) {
id = persister.getIdentifier( entity, source );
if ( id == null ) {
throw new IdentifierGenerationException(