I'm developing a webapp which needs access to two different database servers (H2 and Oracle). The container is an Apache Tomee 1.5.1 and I'm using the Java EE stack with libraries provided in it (JSF, JPA, CDI, EJB, etc.).
I'm trying to use two entity managers inside an XA transaction to extract data from the Oracle database and persist it in the H2 after transforming it, BUT all the queries are executed against the H2 database no matter the entity manager I use. I found that if I try to access the entity managers in inverse order, they behavior is the same but accessing to Oracle. I.e.: the entity managers stay with the first database accessed. Any help? The EJB where this happens (calling service.getFoo() from JSF): The resource producer (CDI) for the entity managers (where @H2Database and @OracleDatabase are qualifiers): My peristence.xml looks like this: And finally, the data sources inside tomee.xml (there aren't any other data sources configured inside this file): -- View this message in context: http://openejb.979440.n4.nabble.com/Why-different-persistence-units-with-separated-data-sources-query-the-same-data-source-tp4661397.html Sent from the OpenEJB User mailing list archive at Nabble.com.
