[jboss-user] [JBoss Seam] - Re: How many EntityManagers and SFSBs in a web app?

petemuir do-not-reply at jboss.com
Thu Dec 7 17:02:23 EST 2006


You really seem to have missed the point.

If you use a Seam Managed Persistence Context (RTM) then it solves the LIE situation for conversations (which can be used 99% of the time you used to use the session scope).

I suspect the problem is that you are using session scoping when you needn't.  I think it is fair to say that you should, in most normal apps, only need to store one entity in the session scope - the logged in user - and I've never had to place any in the application context.

anonymous wrote : The problem is, how do I avoid LazyInitializationExceptions when my objects have collections in them? Obvious answer: use eager fetching. But for situations where that is not practical, the thing to do is to have an EntityManager available while the page is being rendered.

No.  The obvious answer is to use a conversation and a conversation scope entity manager (which Seam does for you) (and certainly provides the same entity manager whilst the page is rendered.


anonymous wrote :  I can access the FacesMessages from any object and the FacesMessages is retrieved from the Thread itself.

Thats because FacesMessages is conversation scoped.  An EXTENDED persistence context isn't, an SMPC is.

petemuir wrote : For SESSION and APPLICATION scopes either eager fetch what you need or create a manager that reloads entities when they become detached (this is somewhere in the forum archive).

I forgot I wrote this up:

http://wiki.jboss.org/wiki/Wiki.jsp?page=SeamEntityHomeForLongRunningContexts

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

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



More information about the jboss-user mailing list