[jpa-spec users] [jsr338-experts] Re: Re: Thread safety for injected EMs

From: Christian von Kutzleben <>
Date: Thu, 27 Jun 2013 10:10:08 +0200

Hi Kevin,

There seems to be a lot of conflicting information on the web concerning
>>> the thread-safety of injected EMs in runtime components. From a
>>> WebSphere perspective, our injected EMs are thread-safe regardless of
>>> the runtime component -- EJBs or Servlets. But, there are several
>>> references that indicate injected EMs in a Servlet are not thread-safe
>>> [1, as an example]. Our JPA spec is not clear on this (or, at least I
>>> couldn't find a definitive answer). What's the consensus of the group?
>>> Should injected EMs in a Servlet be considered thread-safe? Or, is
>>> this an implementation detail left up to each application server?
The injected instance implementing EntityManager could of course be made
however, this only synchronizes threads accessing the underlying
persistence context through
the EntityManager interface and threads, accessing the persistence context
otherwise would
corrupt the data (specifically: field/property access of instances, which
cause delayed/lazy loading)

So IMO only the JPA implementation could provide means for thread-safety,
but this is not a required
feature, so from my point of view, unless a thread-safe feature would be
introduced to JPA and the
"injector" enables this, this can not work at all.

(Personally, I'm in favor of not introducing such a feature; we had that in
the JDO spec and it just
creates unnecessary complexity and issues to only support some corner


*Christian von Kutzleben*
Chief Software Engineer
Versant GmbH, Subsidiary of Actian Corporation
PHONE +49 40 60990-273
FAX +49 40 60990-113
Versant GmbH is incorporated in Germany. Company registration number: HRB
54723, Amtsgericht Hamburg. Registered Office: Halenreie 42, 22359 Hamburg,
Germany. Geschäftsührer: Marc Monahan, Fred Gallagher, Volker John
[image: Facebook-icon] <>[image:
Twitter-icon] <>[image:
You-Tube-icon] <>[image:]<>
*[image: cid:image001.jpg@01CC7916.C4DCFC40] <>*
This transmission is confidential and intended solely for the use of the
recipient named above. It may contain confidential, proprietary, or legally
privileged information. If you are not the intended recipient, you are
hereby notified that any unauthorized review, use, disclosure or
distribution is strictly prohibited. If you have received this transmission
in error, please contact the sender by reply e-mail and delete the original
transmission and all copies from your system.

(image/png attachment: image002.png)

(image/png attachment: image001.png)

(image/png attachment: image004.png)

(image/jpeg attachment: image007.jpg)

(image/png attachment: image003.png)

(image/png attachment: image008.png)