HHH-13815 TransientObjectException after merging a bidirectional one-to-many with orphan deletion

This commit is contained in:
Andrea Boriero 2024-12-13 17:55:15 +01:00 committed by Andrea Boriero
parent 4d7bb44d01
commit fefadfe6ea

View File

@ -1295,8 +1295,8 @@ protected static <E> Collection<E> getOrphans(
// iterate over the *old* list
for ( E old : oldElements ) {
if ( !currentSaving.contains( old ) ) {
final Object oldId = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, old, session );
if ( !currentIds.contains( useIdDirect ? oldId : new TypedValue( idType, oldId ) ) ) {
final Object oldId = ForeignKeys.getEntityIdentifier( entityName, old, session );
if ( oldId != null && !currentIds.contains( useIdDirect ? oldId : new TypedValue( idType, oldId ) ) ) {
res.add( old );
}
}