I'm working on a client/server app in jboss ejb3.
If i want to undo a deletion of an object, i call em.persist(o), where o used to be a detached instance, but has been em.remove(o) in an earlier transaction.
This persist() invocation gives the "passing detached instance to persist" because hibernate thinks the thing is still detached (probably because the deletion of that entity did not affect my remote detached entity in the client app, but i do use that detached remote entity to persist again).
So to make this work, i have to clear the id of my entity: by doing that, hibernate no longer thinks the entity is detached, and accepts the persist(), and generates new ids.
The problem is, that the entity is actually a tree of entities.
What i'm looking for, is some method that clears the ids of my entity and all related ones, following the cascading rules for persist.
|