[jboss-user] [EJB 3.0] - Re: Manually created Hibernate EntityManager vs. injected on

skajotde do-not-reply at jboss.com
Thu Nov 13 08:15:00 EST 2008


JBoss uses EnityManager which is involved with TransactioManager and em is proxy so em.find/em.save is thread safe.

Your code is also thread safe because beans are thread-safe but creating emtnity manager factory has high cost (6 seconds on my machine). 

Persistence.createEntityManagerFactory("em");

Should be invkoned once.

If you move creating emf to singleton then there is question if emf.createEntityManager(); has proper transaction if you are using annotations on beans. If you using transactional filter (eg. on web.xml in web apps) which global begin/commit transaction there should be no problem.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4189077#4189077

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4189077



More information about the jboss-user mailing list