Showing posts with label load. Show all posts
Showing posts with label load. Show all posts

Thursday, June 5, 2014

hibernate: get vs load

The difference between get() and load() methods of class Session is


get(Student.class, 234) -  returns the entity instance of the class(Student) from  table student matched with the unique identifier value 234.

load(Student.class, 234) - returns the entity instance of the class(Student) from  table student matched with the unique identifier value 234.

But the exact difference between them is get returns null when there is no match in the DB table while,  the load method throws exception "org.hibernate.ObjectNotFoundException: No row with the given identifier exists".