users@glassfish.java.net

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

From: Jason Lee <lee_at_iecokc.com>
Date: Fri, 16 Mar 2007 10:40:06 -0500

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?

-----
Jason Lee, SCJP
Senior Software Engineer
http://www.iec-okc.com
 

> -----Original Message-----
> From: glassfish_at_javadesktop.org [mailto:glassfish_at_javadesktop.org]
> Sent: Friday, March 16, 2007 10:39 AM
> To: users_at_glassfish.dev.java.net
> Subject: Re: Surprising JPA (Toplink) Behaviour (glassfish v1 UR1)
>
> [i]I don't think caching should be turned off by default, but
> I do think that it is very weird for JPA's internal cache to
> not be updated when you make a change using the entity
> manager, then load the same entity again using the same
> entity manager. I would expect the loaded entity to be up to
> date. [/i]
>
> Ok, well that may be the issue. Each subsystem is getting a
> different EntityManager from the EntityManagerFactory each
> time it needs to interact with the persistent store.
>
> Is that contrary to what should be done? Should I keep an
> EntityManager singleton around somewhere and have all code use it?
>
> (Are they thread-safe, BTW?)
> [Message sent by forum member 'pohl' (pohl)]
>
> http://forums.java.net/jive/thread.jspa?messageID=208426
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>