Difference between get and load in hibernate

In this post, we will see differences between get and load in hibernate. It is most asked interview question on hibernate.

Tutorial Content:

Before we actually see differences, let me give you brief introduction of both.


  • session.get() method always hits database and returns actual object
  • It returns null in case it does not get object.


  • session.load() method always does not hit database and returns proxy object
  • It throws  ObjectNotFoundException  in case it does not get object.

 get vs load in hibernate

Database retrieval
It always hits the database
It does not hit database
If null
If it does not get the object with id, it returns null
If it does get the object with id, it throws ObjectNotFoundException
It returns real object
It returns proxy object
If you are not sure if object with id exists or not, you can use get
If you are sure about existence of object, you can use load

Related Posts

Leave a Reply

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

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.