cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple persistent units

Former Member
0 Kudos

Hi,

I have one EJB project with two beans refering to two different data bases using two persistence units.

Bean A - persistence unit DB_A_unit - entity class CL_A - table DB_A

Bean B - persistence unit DB_B_unit - entity class CL_B - table DB_B

In persistence.xml I defined both units with different data source aliases.

Now I try to execute a method of bean A and get the exception:

The persistence unit is inconsistent with the database schema

The table DB_B does not exist.

If I try to execute a method of bean B I and get the exception:

The persistence unit is inconsistent with the database schema

The table DB_A does not exist.

Why does a method call in bean A affect the entity of bean B? How can I avoid this?

Thanks,

Kevin

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I found a solution:

<persistence-unit name="DB_A_unit">

<jta-data-source>a_alias</jta-data-source>

<class>CL_A</class>

<exclude-unlisted-classes>true</exclude-unlisted-classes>

</persistence-unit>

<persistence-unit name="DB_B_unit">

<jta-data-source>b_alias</jta-data-source>

<class>CL_B</class>

<exclude-unlisted-classes>true</exclude-unlisted-classes>

</persistence-unit>