This content has been marked as final.
Show 2 replies
-
1. Re: Session scoped persistence context (SMPC)
asookazian Dec 31, 2009 1:21 AM (in response to hendinas.hendinas.gmail.com)/** * A Seam component that manages a conversation-scoped extended * persistence context that can be shared by arbitrary other * components. * * @author Gavin King */ @Scope(ScopeType.CONVERSATION) @BypassInterceptors @Install(false) public class ManagedPersistenceContext implements Serializable, HttpSessionActivationListener, Mutable, PersistenceContextManager, Synchronization {...}
SMPC is conversation-scoped.
-
2. Re: Session scoped persistence context (SMPC)
blabno Jan 4, 2010 10:37 AM (in response to hendinas.hendinas.gmail.com)It is a terrible idea from performance point of view. Although you could make your own entity manager factory which would put entity manager in session scope (if you really cannot reconfigure the one Seam provides).
Your case is that entities are being detatched after first request that retrives them ends (cause entity manager gets closed and next request will use different one). You could :
- call entityManager.merge at the begining of each request,
- initialize needed associations during first request or mark them as EAGER
- do not access associations via #{mySessionScopedEntity.someAssociation} but rather make a list component (i.e. EntityQuery) that will retrive associated items (this is good for viewing associated items, but updating them will outdate your sessionScopedEntity, which you would have to refresh)