0 votes
in Hibernate by
What is the difference between get and load method?

1 Answer

0 votes
by

The differences between get() and load() methods are given below.

No.                      get()                                                                    load()

1) Returns null if an object is not found. Throws ObjectNotFoundException if an object is not found.

2) get() method always hit the database. load() method doesn't hit the database.

3) It returns the real object, not the proxy. It returns proxy object.

4) It should be used if you are not sure about the existence of instance. It should be used if you are sure that instance exists.

...