Hibernate - Explain the difference between load()
and get() in Hibernate. - Feb 04, 2009
at 8:10 am
by Vidya Sagar
Explain the difference between load() and
Difference between load() and get()
Use this method if it is sure that
the objects exist.
The load() method throws an exception,when the unique id could
not found in the database.
The load() method returns proxy by default and the data base will
not be effected until the invocation of the proxy.
Use this method if it is not sure that
the objects exist.
Returns null when the unique id is unavailable in the database.
The data base will be effected immediately.
Hibernate - Explain the difference between
load() and get() in Hibernate. - Nov 19, 2009 at 12:10 pm
by Amit Satpute
Explain the difference between load() and get() in
- Session.get() returns a fully initialized instance which is
fully available in any future detached state.
- This was actually aligned in Hibernate3 with the
EntityManager.find() operation, which has been standardized that
- Session.load() or EntityManager.getReference() should be used
if a fully initialized instance is not needed, which saves a
database roundtrip if nothing other than creation of an
association is done, with the proxied instance in managed state.
- The instance data is then not available fully in detached
- If working with detached objects is not needed, load() or
getReference() can be used to get the extra optimization of
proxies in Hibernate.
-load() should be used only if an object
exists else using get() is appropriate.
-load() throws an
exception if the unique id is not found in the database while
get() returns NULL.
-load() returns a proxy by default and
database won’t be hit until the proxy is first invoked while get()
will hit the database immediately.
Entity beans are to be implemented by containers, classes,
descriptors. Hibernate is just a tool that quickly persist the
object tree to a class hierarchy in a database and without using a
HibernateTemplate is a helper class that is used to simplify the
data access code. This class supports automatically converts
HibernateExceptions which is a checked exception into...............