[jboss-user] [EJB 3.0] - Re: BMT does not work the expected way.

waynebaylor do-not-reply at jboss.com
Thu Jul 26 15:03:42 EDT 2007


>From the EJB3 Persistence spec (section 5.3, page 116) it says to use:
EntityManagerFactory emf =
  | javax.persistence.Persistence.createEntityManagerFactory("Order");
  | EntityManager em = emf.createEntityManager();
when working in a Java SE environment. 

When working in an EE container use injection/JNDI lookup. For example:
@Stateless
  | @TransactionManagement(TransactionManagementType.BEAN)
  | public class TravelAgentBean {
  | 
  | @PersistenceUnit(unitName="titan")
  | private static EntityManagerFactory factory;
  | ...}
  | 

ps. you can get a UserTransaction with: @Resource UserTransaction tx; if you want to avoid the jndi lookup.

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

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



More information about the jboss-user mailing list