Number Of Page View:100,000+/Months
LOGIN |New User


Difference between session.update() and session.lock() in Hibernate ?
Both the session.update() and session.lock() are intended for re-attaching a detached object. The session.lock() method simply reattaches the object to the session without checking or updating the database on the assumption that the database in sync with the detached object.
It is the best practice to use either session.update() or session.saveOrUpdate().
Use session.lock() only if you are absolutely sure that the detached object is in sync with your detached object or if it does not matter because you will be overwriting all the columns that would have changed later on within the same transaction.