HHH-16825 Cascading an entity with a composite key causes NullPointerException in AbstractClassJavaType.extractHashCode

This commit is contained in:
Andrea Boriero 2023-07-24 12:39:08 +02:00 committed by Andrea Boriero
parent b66ba5ff0c
commit bf9a8283dc
1 changed files with 4 additions and 3 deletions

View File

@ -221,9 +221,7 @@ public class DefaultMergeEventListener
final EventSource session = event.getSession();
final String entityName = event.getEntityName();
final EntityPersister persister = session.getEntityPersister( entityName, entity );
final Object id = persister.hasIdentifierProperty()
? persister.getIdentifier( entity, session )
: null;
final Object id = persister.getIdentifier( entity, session );
final Object copy = copyEntity( copyCache, entity, session, persister, id );
// cascade first, so that all unsaved objects get their
@ -233,10 +231,13 @@ public class DefaultMergeEventListener
copyValues( persister, entity, copy, session, copyCache, ForeignKeyDirection.FROM_PARENT );
saveTransientEntity( copy, entityName, event.getRequestedId(), session, copyCache );
persister.setIdentifier( entity, persister.getIdentifier( copy, session ), session );
// cascade first, so that all unsaved objects get their
// copy created before we actually copy
super.cascadeAfterSave( session, persister, entity, copyCache );
copyValues( persister, entity, copy, session, copyCache, ForeignKeyDirection.TO_PARENT );
// saveTransientEntity has been called using a copy that contains empty collections