Hi,
If I try to update an object loaded in the same session, by calling one of the setter and then flush(), if the new value of the property is the same like the old one, no update is issued to the DB.
Session session = ...
Person person = session.find(...)
person.setName("sameName") // same value as in the person object
session.flush();
session.close();
On the other hand, if I load Person in a previous session and try to update in a new one, an update is issued to the DB even if nothing changes in the object's fields
Session session = ...
Person person = session.find(...)
session.close();
Session session1 = ...
person.setName("sameName") // same value as in the person object
session1.update(); // or saveOrUpdate()
session1.flush();
session1.close();
Why is that? Can I achieve the same functionality as in the first case?
Thanks,
--steve
|