1600 PMP mock questions 1400 CAPM mock questions 800 SCJP 6 mock questions 600 OCAJP 7 mock questions 590 OCPJP 7 mock questions 556 SCWCD 5 mock questions 500 OCEJWCD 6 mock questions pdfDownload (java,struts, hibernet etc)

Hibernate interview questions

!!! Hibernate interview questions !!!

Difference between session.load() and session.get() ?




load() will throw an unrecoverable exception if there is no matching database row.
get() will return null if there is no matching database row.


Cat fritz = (Cat) session.load(Cat.class, "1");

Return the Cat Object with key 1. If there is no Cat Object with key 1 then throw will throw an unrecoverable exception.

If the class is
mapped with a proxy, load() just returns an uninitialized proxy and does not actually hit the database until you
invoke a method of the proxy. This behaviour is very useful if you wish to create an association to an object
without actually loading it from the database. It also allows multiple instances to be loaded as a batch if batchsize
is defined for the class mapping.


Cat fritz = (Cat) session.get(Cat.class, "1");
If you are not certain that a matching row exists, you should use the get() method, which hits the database immediately
and returns null if there is no matching row.

Reviews and Comments


PMP, CAPM, PMI is a registered certification mark of the Project Management Institute, Inc

Copyright © www.techfaq360.com 2016


About US | Contact US | Privacy Policy | Terms and Conditions  | Website disclaimer  | Cancellation and Refund Policy  | Shipping & Delivery Policy