1.load() and get()
| load() | get() |
Only use the load() method if you are sure that the object exists. | If you are not sure that the object exists, then use one of the get() methods. |
load() method will throw an exception if the unique id is not found in the database
| get() method will return null if the unique id is not found in the database. |
load() just returns a proxy by default and database won’t be hit until the proxy is first invoked. | get() will hit the database immediately. |
2.merge() and update()
Use
update() if you are sure that the session does not contain an already persistent instance with the same identifier, and
merge() if you want to merge your modifications at any time without consideration of the state of the session.