Monday 14 October 2013

Difference between load and get method of the Hibernate


Difference between load and get method of the  Hibernate





Get
Load
Hibernate Session class returns null if object is not found in cache as 
well as on database
load() method throws ObjectNotFoundException if object is not found on cache as well as on database but never return null.
Get method never returns a proxy, it

 either returns null or fully initialized 

Object
load() method may return proxy, which is the object with ID but without initializing other properties, which is lazily initialized.
Get method will result in slightly lower performance,
load method will result in slightly better performance,
Get method always hit database
load() method may not always hit the
database

No comments:

Post a Comment

Very Impotent Links for Java and Portal development development

Jar Download for Spring  Maven Or Gradel Dependency for Spring