Skip to content

Commit

Permalink
HHH-2862 Throw error instead of replacing collection with same key
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Jan 16, 2025
1 parent 57b8637 commit a920bf1
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1090,13 +1090,9 @@ private void addCollection(PersistentCollection<?> coll, CollectionEntry entry,
if ( old == coll ) {
throw new AssertionFailure( "bug adding collection twice" );
}
// or should it actually throw an exception?
old.unsetSession( session );
if ( collectionEntries != null ) {
collectionEntries.remove( old );
}
// watch out for a case where old is still referenced
// somewhere in the object graph! (which is a user error)
throw new HibernateException(
"Found shared references to a collection: " + collectionKey.getRole()
);
}
}

Expand Down

0 comments on commit a920bf1

Please sign in to comment.