IrfanAnsari wrote:
I have a persistent object and on UI , I'm displaying all the attributes , and now user hjas changed some of the attributes and trying to save.
In this case I have to update the persisted object the modified one.
I'm wondering , if there is only way just load the persistent object and the modify each and every attributes.
This would be easier if you had provided a code snippet, but I think I hear that you are attempting the following:
1. Loading and object (cat).
2. Send (cat) to the user.
3. User modifies (cat) then passes back.
4. Loading a second instance of same object (secondCat)
5. Copy field for field, including id (cat) to (secondCat)
6. Save (secondCat)
This is a classic detached objects scenario and the documentation is quite clear on how to do this. It is not necessary to reload the cat and do the field by field copy. A simple update() on the original cat would suffice.
If you are performing this work all with in the same Session, then it is even easier: (straight form the manual):
Code:
Cat fritz = (Cat) sess.load(Cat.class, id);
// pass it out to UI and modify fritz, then send back
sess.flush(); // persist changes to DB.
Hope that helps,
John