What is the difference between Hibernate get() and load() methods?
What is the difference between Hibernate get() and load() methods?
Hibernate session’s get() method is used to retrieve an object from the database using a unique Id. The method returns null if the object is not found in the database. If the object is not available in cache, but exists on database, it may involve several data access calls to database returning a completely initialized object.
Hibernate session’s load() method is also used to retrieve an object from the database using a unique Id. However this method throws an exception if the object is not available in the database. If the object is not available in cache, but exists on database, load() method can return proxy in place providing lazy initialization which results in better performance.