Hello, I'm developing an application and I have to use the same JPA beans in multiple databases in the same application. The solution that I've thought is to create various persistence units, one for every database and use them in my beans. The problem of this approach is that I cannot use the @PersistenceContext or @PersistenceUnit annotations since the persistence unit for those elements is fixed and I need to get it programatically. On every request I have to decide which database to use.
I tried using the Persistence.createEntityManagerFactory call in my EJB but it fails because my datasource (and my persistence unit) are configured to use JTA and I get the error:
Caused by: org.hibernate.HibernateException: The chosen transaction strategy requires access to the JTA TransactionManager