-
1. Re: Seam Persistence Context in Session scope
amitev Mar 3, 2010 9:43 AM (in response to sudhu72)I would NOT recommend a session-scoped SMPC. Everytime it loads an object it will be stored in the first-level cache for the entire session which may result to OutOfMemoryError.
I recommend you to carefully design your conversations and begin/end points. It's not that hard actually. Look at the conversation as a Unit of work. When the user opens something for edit, changes some data and saves the changes - this is one unit of work hence one conversation. -
2. Re: Seam Persistence Context in Session scope
asookazian Mar 9, 2010 8:19 PM (in response to sudhu72)I agree with AMitev.
How did you change the SMPC scope from conversation to session?
Here is the code:
/** * 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 {...}
If the entities are being prematurely detached, this is usually due to the persistence context closing. If you use SMPC with Hibernate manual flush, the persistence context stays open during the LRC and this prevents Hibernate LIEs and premature detachment of entities.
-
3. Re: Seam Persistence Context in Session scope
sudhu72 Mar 11, 2010 4:56 AM (in response to sudhu72)I added the attribute scope="session" in the component tag for the Managed Persistence Context in components.xml.
What is the difference between flush mode manual and the default, which I believe is auto?
Also is there a best practice for how the persistence context should be opened and kept open so as to handle the LIEs as well as not affect performance adversely?
Thanks a lot
--cogito ergo sum -
4. Re: Seam Persistence Context in Session scope
amitev Mar 11, 2010 9:43 AM (in response to sudhu72)Flush-mode=auto will flush insert/update sql when the transaction commits. Flush-mode=manual will flush insert/update sql when you call .flush().
-
5. Re: Seam Persistence Context in Session scope
sudhu72 Mar 11, 2010 4:29 PM (in response to sudhu72)The reason I asked about manual flush is that it is tantamount to bean managed transaction.
I wanted to avoid it as a practice in a project with many developers, because if any user doesn't call flush it might result in unpredictable behaviour.
Also, if it not flushed for too long it might be as bad a persistence context with session scope.