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?

  1. annotate doit() @transactional?
  2. calculate result inside method annotated @transactional?
  3. manually doing stuff opensessioninviewfilter doing servlet requests?
  4. utilizing type of "ready use" filters or interceptors websockets in spring (which one, how, examples?)
  5. tomcat websocket filter?

right i'm voting 3, looks uncool... ;-)


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -