|
From: Per O. <po...@no...> - 2005-02-14 14:54:08
|
Hi, On Monday 14 February 2005 15:06, you wrote: > It's good that you are considering the exceptional circumstances when using > Hibernate. OpenSessionInView (OSIV) is certainly seductive because of its > ability to support lazy-loading while the view is being rendered. Once you > go beyond the realm of the simple application and have to support > exceptional circumstances, OSIV can be very problematic. > > I think you will continue to run into other use cases where OSIV causes > undesirable behavior, as we did. Eventually, we changed our approach and > went with a service layer (in the spirit of an EJB Stateless Session Bean) > that clearly demarcates the Hibernate Session and database transactions. It > has made our life much easier and more deterministic. The only drawback is > that the service layer is responsible for eager loading the lazy-loaded > collections prior to the view rendering. Your comments hit right on the considerations we had on using it or not. It also seems that there are different thoughts on the spring lists about if it is good or bad. Maybe we should provide some more documentation/information in spring with considerations on if you should be using it or not? I think many folks start using it without realizing the consequences. I would be glad to start it with my thoughts on the subject! Personally, I think there is room for it in some projects, mine included :-) We experience fast and seamless development of new view pages, when we do not have to think about precisely which parts of the model, we need to eager load. But, I was more thinking about if the actual solution of spring using session.clear() is safe enough, or if I should keep going with my own solution here? Or if maybe spring should take another solution? Any thoughts on that? Regards, Per -- Per Olesen @ Nordija A/S - www.nordija.com - main#: +45 70 20 25 10 email: po...@no... - cell#: +45 23 38 95 81 |