sw79 wrote:
Quote:
I may use replication(obj, ReplicationMode.OVERWRITE) or setVersion() + merge()?
(also many other questions burn when i try implement this behavior)
Thnx.
I think the manually setting of the Version can be dangerous, because an another user can in this time edit the same data and thus increment the Version, in this case you will try to save the object with the same version as the object stored by another user.
Probably I or You do not understand the question correctly.
:)
Look at this code example, which written by me.
Customer dbObj = (Customer) session.get(Customer.class, myObj.getId());
myObj.setVersion(dbObj.getVersion());
session.merge(myObj);
where
dbObj - object version in DB, which has been saved while we thinking about changes on our object (во .а.ну. Ж))
myObj - our object with our changes
Realy we change only version of our object (not in DB), because we give version from DB and set this version for our object and than merge object.
Even if 3d (4d ...) user also change any property, our version can not be same, because we not edit(increment) version in DB (we tune our version to DB version ;)) and we will give StaleObjectExecption =-O.
So, how we can kill this recursion (ofcourse if first part of implementation completely good) ?
Rate/comment this idea plz.