Hey All,
Here's the abstracts of what I have going on...
In the first JVM, we've got a whole Hibernate persistence layer working for us. As an object in the object graph is updated, we send a COPY of the the entire graph over a WS interface to the second JVM. The second JVM now needs to take the data and put it into another (legacy) DB...
The transactions are always one-way between the first and second JVM. (We implemented equals() well so there shouldn't be problems with that...)
So, basically in the second JVM, I have a transient version of some object graph, which may or may not already have a stale version of the same objects in the DB.
My question is, how do I get the new information in the transient version of the object graph into the DB, without creating multiple multiple rows, or having Hibernate pitch a fit, because the data already exists (in a stale state)?
We are currently working around this by exposing (for reading only) the internal generated ID in the 1st JVM, and using that ID as the ID in the tables of the 2nd JVM. But, this kind of feels like a hack...
I've read about the merge() function, but that doesn't seem like it would solve our problems. (I think it assumes we're working with a DETATCHED object, not "overlaying" the data from a transient object graph...)
One other possible solution is to write a deep copy functionality, but that seems like it'd be overly tedious.
Is there an "overlay()" capability to assemble data between an updated TRANSIENT version of the data with a stale PERSISTED version of the data. How else do we solve this?
|