What is the difference between load() and get() method in Hibernate?

In Hibernate, load() and get() methods are quite similar in functionality.

The main difference is that load() method will throw an ObjectNotFoundException if row corresponding to an object is not found in the database.

On the other hand, get() method returns null value when an object is not found in the database.

It is recommended that we should use load() method only when we are sure that object exists in database.

Read the full book at www.amazon.com
Posted in Hibernate, Hibernate Interview Questions

Leave a Reply

Your email address will not be published. Required fields are marked *