|
From: Colin Y. <col...@gm...> - 2006-07-28 22:06:24
|
Hi Bill, Hibernate3 only makes relationships lazy by default, not the class. This is sensible (in my opinion) because most of the time there is no real reason to load the class in seperate chunks (aka field groups). I believe that they actually mention in their documentation that they only support lazy loading of the class in order to "tick a box" :) Also, checking out the hibernate document for the hibernate Session ( http://hibernate.org/hib_docs/v3/api/org/hibernate/Session.html#load(java.lang.Class,%20java.io.Serializable)) indicates that the load methods *do* check that the object exists. So hibernate will throw its HibernateException and Spring will then convert this into one of its own DataAccessException. HTH. On 26/07/06, Bill Six <bil...@ya...> wrote: > > 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 > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > > _______________________________________________ > Springframework-developer mailing list > Spr...@li... > https://lists.sourceforge.net/lists/listinfo/springframework-developer > > > > |