[jboss-user] [JBossWS] - Re: avoid lazy-initialization exceptions

euvitudo do-not-reply at jboss.com
Thu Feb 14 13:35:30 EST 2008


Even if you create another layer of DTOs, you'll still have to handle this case.  I actually created such a layer and transformers to convert the Entities to DTOs (and vice-versa).  The code has a relatively ugly solution, but it works.

The solution was to create a handler that catches all RuntimeExceptions when the transformation code iterates through to the collections.  The handler looks for LazyInitializationException;  if found, it logs the exception (but does not re-throw), if not found, it rethrows the (non-LIE) RuntimeException.

Yeah, ugly, but it works.  The layer essentially removes external dependence on Hibernate.  I suppose an alternative is to submit a bug report (or feature request?) to Hibernate.  Alas, my hack gives me a (false?) sense of security until a Hibernate change causes the hack to break!  YMMV and all.  :)

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4129469#4129469

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4129469



More information about the jboss-user mailing list