Ok. I fixed a couple of things in the sample: I modified the data sources so
that each one points to an individual H2 database and activated OpenJPA
SynchronizeMappings feature with buildSchema(ForeignKeys=true) for both
units. Now it is even simpler. Logs show what I'm saying:

When I get the entity managers, whatever the persistence unit it is bound
to, they all point to the same datasource:

MonitorTareas.java:59
        public void updateEstado() {
                EntityManager emFenix = emfFenix.createEntityManager();
                EntityManager emRadar = emfRadar.createEntityManager();

Corresponding log lines:

22687  FenixPU  TRACE  [main] openjpa.Runtime - Found datasource1:
datasource *17794055 *from configuration. StoreContext:
org.apache.openjpa.kernel.BrokerImpl@617029
22687  FenixPU  TRACE  [main] openjpa.Runtime -
org.apache.openjpa.persistence.EntityManagerFactoryImpl@6d41c0 created
EntityManager org.apache.openjpa.persistence.EntityManagerImpl@617029.
71235  RadarPU  TRACE  [main] openjpa.Runtime - Found datasource1:
datasource *17794055 *from configuration. StoreContext:
org.apache.openjpa.kernel.BrokerImpl@330f22
71235  RadarPU  TRACE  [main] openjpa.Runtime -
org.apache.openjpa.persistence.EntityManagerFactoryImpl@c1918e created
EntityManager org.apache.openjpa.persistence.EntityManagerImpl@330f22.

What's wrong?

P.D.: I updated the download. The same link applies.




--
View this message in context: 
http://openejb.979440.n4.nabble.com/Why-different-persistence-units-with-separated-data-sources-query-the-same-data-source-tp4661397p4661809.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to