[jboss-user] [JBoss Seam] - Re: Getting LazyInitializationErrors with a SMPC

norman.richards@jboss.com do-not-reply at jboss.com
Tue Dec 26 22:58:14 EST 2006


Just to lend some flavor to this, the key points are that to avoid a LIE, an entity has to be attached to an active persistence context and there has to be a be an active transaction.

The seam managed persistence context is one that has it's lifecycle associated with a conversation.  As long as the conversation remains active, the persistence context is active and you will never get a LIE.   (well, assuming there is a tx, which is what the transactional phase listener provides)

I assume the reason you were failing is that your PC was not in long-running conversation.  As soon as your request ended, your short-lived PC died and your entity became detached and you could no longer access unloaded relations. Note that it doesn't strictly matter whether the entity is stored in the session or in the conversation - it matters that the PC for the original conversation is still active.  It's obviously not a bright idea to store a conversation-scoped entity in the session, but it would work.


(I hope that didn't confuse the issue any more)




View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3996373#3996373

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3996373



More information about the jboss-user mailing list