Community

I'm having a hard time with this error "org.hibernate.LazyInitializationException: failed to lazily initialize"

reply from Flemming Harms in EJB 3.0 - View the full discussion

I found a solution to my problem. But I'm a bit unsure if this how it suppose to work.

 

So it turned out when I call a PojoB from PojoA the transaction that was started is not propagate to PojoB(which i thought) and therefore it start a new that is complete separated from the main transaction. But if I lookup the transaction manager through jndi in PojoA before I call the PojoB I can manual start a transaction and then it seems to be running inside the main transaction

UserTransaction userTx = (UserTransaction) ctx.lookup("UserTransaction")
userTx.begin();
pojob =  ctx.lookup("pojob");  
pojob.domystuff();
userTx.commit();
....
...

Any body that can confirm this is how it suppose to work?

 

/Flemming

Reply to this message by going to Community

Start a new discussion in EJB 3.0 at Community