Please Visit: http://ift.tt/1ajReyV
from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/1ivit1s
via LifeLong Community
Improve your life Through Science and Art: JPA: Thread-safety when injecting EntityManager
One way to fix this is to inject EntityManagerFactory instead. EntityManagerFactory is guaranteed to be thread-safe. For example:
? (Link->http://ift.tt/1osMiEr) 123456789101112public class EMTestServlet extends HttpServlet { //This field injection is thread-safe @PersistenceUnit private EntityManagerFactory emf; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { EntityManager em = emf.createEntityManager(); //work with em }}http://ift.tt/1osMiEr
http://ift.tt/QkPBOh
One way to fix this is to inject EntityManagerFactory instead. EntityManagerFactory is guaranteed to be thread-safe. For example:
? (Link->http://ift.tt/1osMiEr) 123456789101112public class EMTestServlet extends HttpServlet { //This field injection is thread-safe @PersistenceUnit private EntityManagerFactory emf; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { EntityManager em = emf.createEntityManager(); //work with em }}http://ift.tt/1osMiEr
http://ift.tt/QkPBOh
from Public RSS-Feed of Jeffery yuan. Created with the PIXELMECHANICS 'GPlusRSS-Webtool' at http://gplusrss.com http://ift.tt/1ivit1s
via LifeLong Community
No comments:
Post a Comment