A very close reading of the Javadoc does yield some differences:
get - Return the persistent instance of the given entity class with the given identifier,
or null if there is no such persistent instance. Obtain the specified lock mode if the
instance exists. Returns: a persistent instance or null
load - Return the persistent instance of the given entity class with the given identifier,
assuming that the instance exists. You should not use this method to determine if an
instance exists (use get() instead). Use this only to retrieve an instance that you assume
exists, where non-existence would be an actual error. Returns: the persistent instance or
proxy
I agree it's pretty subtle though.
The Hibernate reference doc
http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#objectstat... is a
little more clear:
"Note that load() will throw an unrecoverable exception if there is no matching
database row. 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."
Cheers!
Rob[/url]
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961061#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...