[jboss-user] [EJB 3.0] - Re: How to get EnitityManager in SLSB without injection??
That is exactly what I am looking for, very useful to switch between persistence units. Excellent Post, Many Thanks! View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4020903#4020903 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4020903 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: How to get EnitityManager in SLSB without injection??
I have manged through jndi lookup EntityManagerFactory emf = (EntityManagerFactory) jndi.lookup("java:/myEntityManagerFactory"); em = emf.createEntityManager(); View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993861#3993861 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993861 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: How to get EnitityManager in SLSB without injection??
You can just load the EM, no need to go through the factory. I've always done the lookup into an instance variable via resource injection: @Resource(mappedName="theJNDINameOfEM") | private EntityManager em; I believe you shouldn't have to register the EM with the transaction; the container should be doing it for you (it has in all cases I've experienced). S, ALR View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993179#3993179 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993179 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: How to get EnitityManager in SLSB without injection??
Thanks for the response. If I put the entityManager in JNDI, the way you describe, can I just load it from JNDI and then call joinTransaction() on it to make it join the current session transaction, or do I need to load the EntityManagerFactory first and then create the EntityManger from it to make it join the transaction?? View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3993169#3993169 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3993169 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: How to get EnitityManager in SLSB without injection??
Never tried it in the way you've outlined. You can, however, store the EntityManager and EntityManagerFactory in JNDI and look up from there by putting the following in your persistence.xml: | S, ALR View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3992936#3992936 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3992936 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: How to get EnitityManager in SLSB without injection??
anyone?? View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3992895#3992895 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3992895 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: How to get EnitityManager in SLSB without injection??
just to clarify because I made a typo: MyPersistenceUnitName, PurchaseNotification, and MyPeristenceContext should all be the same string View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3992360#3992360 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3992360 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user