posted 9 years ago
Yes. This concept is called dirty checking.
When you get User object from searchUser method , you have not closed the session , so the session is still active.
User user = userManagementServiceImpl.searchUser("aswin");
With the active session , this object is now persistent object which means , when you commit the transaction, Hibernate tries to check with original instance called Dirty changing, if there is any change this will automatically update the data base ;).
This is a cool feature of hibernate, which inside uses the primary level Cache. Read about primary caching and dirty checking - you will understand more.
Regards
Jana