mads1980 wrote:
The idea is to have all business code within the scope of a transaction / Hibernate Session, so that in effect lazy exceptions would not be an issue. However this requires significant thought when designing an architecture and is not always possible. In any architecture where detached objects are present you'll eventually have to solve lazy exception issues, either by eagerly loading whatever is necessary before detaching the objects, or otherwise by having some sort of rule which you obey throughout the app so you know whether you have the data available or not. It's not easy. But no one said enterprise architecture is easy :-)
But then you are not decoupling persistant storage, which is supposed to be an important design pattern.
Your persistance code is embedded in your business logic, or vice versa.
So by using lazy loading, you are breaking one of the main tennants of design patterns.