bastiaanlos wrote:
Aboulafia,
This error means that the object you're tying to delete, still exists in some association of another object.
If you do not remove the object-to-be-deleted form all association-collections, the object would get saved/inserted again when the "parent" object is saved/udated.
So just remove the object-to-be-deleted from the collection first,
( something like category.getSetOfMessages().remove( object-to-be-deleted ),
then call session.delete(object).
[]'s
Unfortunately this method will make Hibernate load the entire collection of Message objects into memory. This is not performant or even possible with very large collections.
We are currently optimising a system where the collections have several thousand entries resulting in minutes of waiting for our users.
On the long term, we are expecting collections with up to 100,000 elements.
The above solution will not even be theoretically possible for this system.
Our solution to adding to a many-to-one collection has been proposed earlier on this forum. The solution is to only set the non-inverse side and don't call collection.add() on the inverse side of the mapping.
BUT: we need a method for removing from a collection. We hope to find a way of doing this without using raw SQL.
Good ideas, anyone?
Best regards
Kim Oechsle