Hibernate version:2.1.6
Name and version of the database you are using:Oracle 9
Have I missed some fundamental mapping concept here, or is Hibernate completey incapable of dealing with modifications to detached objects that contain collections (like most object graphs) ?
I have a web app, domain/data objects loaded on the EJB tier using Hibernate. I have to detach the object graph in order to serve it to the web tier (which renders lazy loading unusable in this very common scenario).
Once on the web tier, the client users make changes to the data in various collections and objects. This modified object is sent back to the EJB, where I attempt to reattach the instance with a new Hibernate session and persist the data - a very common scenario, no rocket science here.
However, Hibernate never stores the collections correctly (properties yes, collections, no) - I always end up with duplicate rows in the DB since it cannot detect the change, (since the Hibernate-wrapped collections can be swapped out on the GUI tier).
Even when I ensure that the Hibernate-provided wrapped collection stays around, emptying that collection (.clear() ) and then repopulating it with the new data values always ends up with duplicate key violations.
What have I missed here?
|