Lets say i have obj1 with a child object obj2.
I also have hibernate running on one machine connected to a database, db1. I have another instance of hibernate running on another machine connected to a different database, db2.
If i serialize obj1 and sent to the second machine via a webservice, how do i get the second instance to persist the deserialized object properly?
The three situations are,
- both obj1, and obj2 haven't arrived at db2 before, we call save with the objects ids.
- both obj1 and obj2 have arrived before, we call update.
- obj1 is new, obj2 is not (or vis versa) and we have to somehow decide which objects to save and which ones to update.
Of course if we call update on a newly arrived object, hibernate will throw a StaleObject exception.
So how do we alter the behaviour to save 'stale' objects on db2?
Hibernate version:2
|