hibernate - How to avoid LazyInitializationException when using WebSockets in Spring? -
any advices how avoid infamous lazyinitializationexception in following setup (working spring , hibernate) :
@messagemapping("/activate/foo") @sendtouser("/queue/result") public result doit(integer fooid) { foo foo = fooservice.load(fooid); // via hibernate result = ... // accessing foo outside hibernate transaction // therefore lazyinitializationexception thrown return result; }
what do?
- annotate doit() @transactional?
- calculate result inside method annotated @transactional?
- manually doing stuff opensessioninviewfilter doing servlet requests?
- utilizing type of "ready use" filters or interceptors websockets in spring (which one, how, examples?)
- tomcat websocket filter?
right i'm voting 3, looks uncool... ;-)
Comments
Post a Comment