Sven, I take it the "moving around" occurs in custom interceptors? You can definitely do your own Hibernate session management in interceptors. I did it myself before I groked AOP and @Transactional. In fact, I think I plagiarized the crux of it from OpenSessionInViewInterceptor. Just be sure you catch the out fault case, or subsequent requests served by the same thread will run into session-already-open problems. Also, since the "sessionFactory.currentSession" context is the current thread (usually?), if that handler chain thread swapping thing Dan Kulp mentioned recently happens, you'll probably break.
Dan On Thu, Jul 17, 2008 at 11:38 AM, Sven Haiges <[EMAIL PROTECTED]> wrote: > Hi all, > > there must be a more elegant solution to an issue I have right now. I am > using CXF to expose a SOAP-based interface to our data layer. This means in > my spring config, I got bith Hibernate setup and also cxf. So calls would > come in, hit the SOAP interface and the service implementations are then > referencing a dataAccess object that does the hibernate calls. > > This works fine, but I now experience the issue that I sometimes have to > move around in my domain model and then some collecitons, references, are > not yet initialized. And as I call those references from outside of the > dataAccess (which opens and closes the hibernate session), I easily get > exceptions. > > My current solution would be to move the hibernateTemplate (from > dataAccess) into my service implementation. During all operations, I would > keep the session open till the very end. This would work, but it also kind > of breaks the separation of concerns paradigm I guess. > > What I actually need is something like the Spring > OpenSessionInViewInterceptor just for CXF calls. A new Hibenrate session > should be opened with each incoming call ot a service method and closed > after completion. > > Is this available fro CXF? If not, would it be diffcult to implement? > > Cheers > Sven > > --- > Sven Haiges > Y! Messenger / Skype: hansamann > >
