Hi guys...
I changed my forge project to use 2 persistence units.
But.. I need change the managed bean generated by "scaffold from-entity", to change units in runtime.
I created a class to use this like a factory:
@Named
@Stateful
@ConversationScoped
public class AppEntityManagerFactory {
public EntityManager getAppEntityManager(){
EntityManagerFactory emf=Persistence.createEntityManagerFactory("forge-default");
EntityManager em=emf.createEntityManager();
return em;
}
}
And in managed bean, I removed @PersistenceContext annotation at entityManager and I changed it to instanciate my class;
private EntityManager entityManager=new AppEntityManagerFactory().getAppEntityManager();
I get this error at debug.
This is my persistence.xml
Hi Marcio,
AFAIK, you can't use transaction-type="JTA" when creating entity managers using your approach.
Best Regards,
George