[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Best Practices for using PersistentContexts in Seam Applicat

karltraunmueller do-not-reply at jboss.com
Mon Nov 26 11:34:01 EST 2007


Hello,

We have a regular Seam 1.2.1.GA Web Application under JBoss 4.0.5.GA with 
- JSF (MyFaces 1.1.4) for the UI,
- (conversation and session-scoped) Seam Components for UI logic,
- EJB3 entity beans for persistence,
- and a POJO-based model for core product logic.

We've had some bugs related to persistence, mainly due to sloppy use of different kinds of PersistenceContexts scattered all over the place, and incorrectly scoped Seam Components (Conversation, Session).

The bugs we face are mainly of the form 
- modify an entity in one Page (= View + associated conversation-scoped Seam Component using some PersistenceContext)
- go to another page (= another View + session-scoped Seam Component using another Persistence Context)
-> and the changes aren't reflected there (because of the mismatched component scoping).

So, my questions are now:

- What kind of PersistenceContext to use? There are three flavors: standard (EJB3), extended (EJB3), and Seam-managed. The standard contexts are applicable in situations where entities are accessed only within the scope of a single EJB method. The extended context is required in lazy-loading scenarios. What about the Seam-managed persistence context? Use it everywhere instead of standard and extended EJB?

- Are there any best practices of where to put the PersistenceContexts and how many to use? Put a single persistence context in some central DAO-Component? Or is it OK to inject it onto several Seam Components

- How about the above scenario (conversation-scoped Component's changes should be reflected in session-scoped Component's persistence context)?

regards,
Karl Traunmüller

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

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




More information about the jboss-user mailing list