I don't know if it is the best place to do it, but...
I am in a big project with JPA(Hibernate), Spring and Richfaces
We built it in a way that we got a great productivity, but the lazy fetch...
I solved it by using OpenEntityManagerInView and since our model is too complicated, we clone some objects whose life continues after a request.
But in my point of view we should not worry about that.
My suggestion is that Hibernate gives us a choice to use a feature, and it could be that the Lazy load engine stores in the persistentBags or proxies a reference to the factory that created the session and when the session is closed, it creates a new session just for the fetch or maybe have an opened session associated to the Thread.
This way we would not worry with lazy loads.
Thx
|