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

get() and load() are both Session methods for retrieving an entity by its identifier, but they differ in what happens when the row doesn't exist and in how eagerly the data is actually fetched.

Key Points

Example

Calling session.get(Employee.class, 99) when no employee with id 99 exists returns null immediately, while session.load(Employee.class, 99) returns a proxy silently and only throws ObjectNotFoundException the moment you call a method like proxy.getName() on it.

Employee e1 = session.get(Employee.class, 99L);   // returns null if missing
Employee e2 = session.load(Employee.class, 99L);  // returns proxy, throws on access if missing

Interview Tip

A concise interview answer is

get() immediately queries the database and returns null if the row isn't found, while load() returns a lazy proxy without querying and only throws ObjectNotFoundException when you actually access it. I use load() when I just need a reference for an association, and get() when I need to check existence.

Last updated: 11 November 2026

Previous question: Describe the Second Level Cache in Hibernate.

Next question: How does Hibernate ensure data integrity?

More Hibernate (Optional) interview questions

All Hibernate (Optional) questions