Example & Tutorial understanding programming in easy ways.

What is the difference between the session.get() method and the session.load() method?

The difference between session.load() and session.get() are as below:


session.load()


In the session.load() it always return a porxy (Hibernate term) without hitting the database. proxy is an object with the given identifier value, its properties are not initilized yet, it just look a temporary fake object.


If no row found, it will throws an ObjectNotFoundException.


session.get()


It always hit the database and return the real object, an object that represent the database row not proxy.


If no row found, it return null.

Read More →