java - is it possible to use @transactional annotation with a transaction opened by hand (spring/hibernate) -


i have spring application works hibernate , annotations. open session hand done in how manually open hibernate session? stack overflow answer.

now want use method of service in method opens session itself. service annotated transactional statement. possible tell method use transaction opened hand?

e.g.

@transactional("transactionmanager") class service1  {     public lazyobject somemethod();  }  class metaservice {     @autowired    sessionfactory sf;     service1 s1;     public somemethod() {         session s = sf.opensession();         s.begintransaction();          // tell method use s's transaction         // without annotating somemethod() @transactional         lazyobject lo = s1.somemethod();          ( lazyatt la : lo.getlazyatt() ) {             la.dosomething();         }          s.flush();         s.gettransaction().commit();         s.close();    } } 

for wondering why want it, check question: https://stackoverflow.com/questions/29363634/how-to-open-two-sessions-in-one-function-in-hibernate-spring


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -