users@glassfish.java.net

RE: Re: EntityManagerFactory vs. EntityManager

From: Jason Lee <lee_at_iecokc.com>
Date: Tue, 13 Feb 2007 07:59:58 -0600

That looks like exactly what I was needing. Thanks for the pointer! :)
 
-----
Jason Lee, SCJP
Programmer/Analyst
http://www.iec-okc.com <http://www.iec-okc.com/>
 


  _____

        From: Shreedhar.Ganapathy_at_Sun.COM
[mailto:Shreedhar.Ganapathy_at_Sun.COM]
        Sent: Monday, February 12, 2007 11:50 PM
        To: users_at_glassfish.dev.java.net
        Subject: Re: EntityManagerFactory vs. EntityManager
        
        
        Hi Jason
        Could you refer to the following from the Blueprints team for a
solution:
        
https://blueprints.dev.java.net/bpcatalog/ee5/persistence/ejbfacade.html

        
        in particular
        
https://blueprints.dev.java.net/bpcatalog/ee5/persistence/ejbfacade.html
#client-caching
        and
        
https://blueprints.dev.java.net/bpcatalog/ee5/persistence/ejbfacade.html
#using_jsf
        
        you can also ask further questions on this forum as the team has
experience with such issues:
        
http://forum.java.sun.com/thread.jspa?threadID=5133945&messageID=9495023
#9495023
        
        hth,
        Shreedhar
        
        Jason Lee wrote:

                Since we migrated our environment to a full Java EE
stack (versus the JSF on Tomcat environment we were using), we've been
injecting an EntityManagerFactory into our JSF managed beans, on the
advice the EntityManager is not thread-safe. We have started, however,
to use more and Session Beans (stateful and stateless) to deploy our
service (and DAO) layers, as we've had the need to expose some of the
business logic in an app to external process, for example. Our "stack"
then, is now basically JSF managed bean/backing bean -> State{ful|ess}
Session Bean service layer -> State{ful|less} DAO layer, which, this
morning, brought up these questions:
                 
                * Do we still need to inject an EMF into our DAO EJB?
                * Does that depend on the statefulness of the bean?
                * Is there a best practice with regard to the
statefulness of a DAO Session Bean?
                 
                I ran into some issues in handling an entity bean
fetched from on EM instance and trying to remove it with another EM
instance, so I'm wondering if I can simplify things a bit by injecting
an EM (or creating the EM from the EMF in a @PostConstruct), or if I
just need to make the API calls to reattach the instance.
                 
                -----
                Jason Lee, SCJP
                Programmer/Analyst
                http://www.iec-okc.com <http://www.iec-okc.com/>