geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tornike <torni...@gmail.com>
Subject EntityManager & Servlets
Date Mon, 31 Aug 2009 10:48:13 GMT

Hi,
I was trying to follow the examples that are given in the Geronimo
documentation to understand JPA. In lot of sources I have read that
EntityManager is not thread safe and it should not be injected into the
servlet. (container managed one) However in the example of ejb-JPA 
http://cwiki.apache.org/GMOxDOC21/container-managed-persistence-with-jpa.html
http://cwiki.apache.org/GMOxDOC21/container-managed-persistence-with-jpa.html 
it is being injected in the servlet.  
[
public class Test extends javax.servlet.http.HttpServlet 
 implements javax.servlet.Servlet {

 static final long serialVersionUID = 1L;

 @PersistenceContext(unitName="AccountUnit")
 private EntityManager em;
]
I have tested the example works without problems so are there conditions
when it can be done or am I understanding it the wrong way?
Thanks.
-- 
View this message in context: http://www.nabble.com/EntityManager---Servlets-tp25221488s134p25221488.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message