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

SmokingAPipe do-not-reply at jboss.com
Thu Dec 7 14:22:27 EST 2006


I'm not ranting.  I'm just trying to figure out how to handle EntityManagers in my application.

Put it another way:

This is a typical web application.  Users log in and then do stuff.  This being a Java application, all the stuff they work on are objects.

JSF and Seam give me excellent ways to display and edit those objects.  EJB3 gives me an excellent way to store those objects without having to write any SQL.  That's great.

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.

What I have done is used Session-scoped SFSBs with extended persistence context.  That sort of works but seems like a bad thing.  What's the right way to handle this?  It seems like such an obvious thing, so there must be some clean way to handle it, right?


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

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



More information about the jboss-user mailing list