Searching in the forum, I found an example of cloning an object through serialization. I tried that approch, but I get an HibernateException: You may not change the reference to a collection with cascade="all-delete-orphan" . why does this happen? The thing is that I'm cloning them to get an exact replic of the Bag object, to be able to detect any orphans.
What I was doing previously serialization was override the clone method and assign a new ArrayList to the collection. but if an object was removed from that cloned collection, the orphan was not deleted, only the reference to the parent object was nullified, leaving trash in the database. Any help would be appreciated.
Martin
|