Question

I'm trying to implement a transaction with 2 different database.
I currently have a persistence unit for each database, and wanted to write on a table A that exists on schema SA and write on a table B on schema SB, on the same transaction.

I'm using weblogic and eclipselink.

I've search a little, but found no example of using multiple persistence units on the same transaction.

Can someone tell me the correct way of doing this?

thank you

Was it helpful?

Solution

Found out that, this should be implemented using XA datasources.
Each persistence unit should use a XA datasource, and then take part on a two-phase commit.

I now have:

  • 2 datasources with driver: oracle.jdbc.xa.client.OracleXADataSource and the credentials to login on both databases
  • each persistence unit is called on a ejb facade, and those ejb facades are called on the global transaction.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top