users@glassfish.java.net

Re: RE: Re: Surprising JPA (Toplink) Behaviour (glassfish v1 UR1)

From: <glassfish_at_javadesktop.org>
Date: Fri, 16 Mar 2007 07:47:59 PST

[i]EntityManager is not thread-safe, and each EM has its own
PersistenceContext, so if you have multiple threads getting an EM from
an EMF, I think they're going to be isolated from each other, so an
update with one EM will not be visible from another EM. Into what kind
of object are you injecting the EMF?[/i]

Ok, so a singleton EntityManager is clearly the wrong thing.

I don't think I even have a singleton EntityManagerFactory. Each subsystem
has an object that keeps its own private static reference to an EMF. Whether
or not they're referring to the same EMF sort of depends upon the semantics
of...

        emf = Persistence.createEntityManagerFactory("FooPU");

...if Persistence.createEntityManagerFactor() returns a singleton, then I have
a singleton factory. If not, then I don't.

Who knows?
[Message sent by forum member 'pohl' (pohl)]

http://forums.java.net/jive/thread.jspa?messageID=208433