the HibernateTemplate is basically a wrapper around the native Hibernate API.
load() just creates a proxy and does not hit the database while get() does.
With load you need to re-attach the owning session somehow, which is only possible by locking it to the saved object. You don't really want to do that if your using the OpenSessionInViewFilter / Interceptor for your views as you will end up with a session remaining locked open
get() will return null if an object is not found while load() will always return a non-null object which is a proxy. If the underlying object does not exist, the proxy will thrown ObjectNotFoundException.
load() should be used when you are sure that the object exits while get() when you're not.
Subscribe to:
Post Comments (Atom)
REFACTORING
What is Refactoring? A software is built initially to serve a purpose, or address a need. But there is always a need for enhancement, fixin...
-
Both SAX and DOM are used to parse the XML document. Both has advantages and disadvantages and can be used in our programming depending on t...
-
If you have ever filled an online form, you are bound to have encountered a CAPTCHA. CAPTCHA stands for Completely Automated Public Turin...
-
This is not my typical technical article, just a little restrospective of an experience at work. I was working with a new member in the t...
No comments:
Post a Comment