|
From: Juergen H. <ju...@in...> - 2006-07-28 21:20:47
|
Interesting suggestion... We usually stick to Hibernate semantics for those methods, that is, do exactly what the Hibernate Session does - just with different exceptions thrown. So in this case, it's recommended to turn Hibernate3's lazy loading off to get an actual loaded object back there. Still, we could consider enforcing initialization ourselves there... Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...] On Behalf Of Bill Six Sent: Wednesday, July 26, 2006 4:08 AM To: spr...@li... Subject: [Springframework-developer] Question/ potential patch fororg.springframework.orm.hibernate3.HibernateTemplate Hi, I have a question about the load() methods on hibernate3's HibernateTemplate. Spring's javadoc for load() say that an exception will be thrown if the object is not found. However, from what I understand, Hibernate 3 changed its default behavior to lazy load all classes. This means that if you try to load an object with an ID that does not exist, a Hibernate error is not thrown because you get a proxy to the object that does not exist. It is only upon the first method call to that proxy that Hibernate's ObjectNotFoundException is thrown. I would think that in Spring's load() methods should force initilization of that object so that trying to load an object that does not exist immediately throws the correct Spring exception. I have attached a patch that should do the trick. I have never made a patch before, nor have I ever looked through the source of spring or hibernate, so please excuse any stupid mistakes :-) Thanks for a great product, Bill Six __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |