This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi I am new to hibernate.
I was searching the difference between load() and get() and this is what I got :
First, when the given ID can’t be found, load() throwsan exception org.hibernate.ObjectNotFoundException, whereas get() returns a null object.
Second,load() just returns a proxy by default; the database isn’t hit until the proxy is first invoked. get() hits the database immediately. The load method is useful when you only need a proxy and don’t need to make a database call. You just need a proxy, when in a given session you need to associate an entity before
I didn't understand the second point. Here what is meant by proxy? Could you please elaborate it?
A proxy is a representation of the "real" object. By default Hibernate creates a proxy for each of the class you map in mapping file. The proxy contains actual method to load the data. when any of the methods in the class are called then the "real" object is touched. You can also look up "lazy Loading/fetching" for more explanation.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley