Hibernate (Java) Question:

Download Job Interview Questions and Answers PDF

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

Hibernate Interview Question
Hibernate Interview Question

Answer:

Both the session.get(..) and session.load() methods create a persistent object by loading the required object from the database. But if there was not such object in the database then the method session.load(..) throws an exception whereas session.get(&) returns null.

Download Hibernate Interview Questions And Answers PDF

Previous QuestionNext Question
How does Hibernate distinguish between transient (i.e. newly instantiated) and detached objects?What is the difference between the session.update() method and the session.lock() method?