Good morning.
Persistence units are distinct and complete object-relational mapping (ORM)
definitions, as per the spec* you cannot really mash two or more distinct
persistence units together. What you need to do is ensure that your
persistence unit (A in this case) includes every class/table that is needed
to complete its ORM. If an entity in A depends on a table mapped by an
entity/mapped superclass in persistence unit B, then that suggests
persistence unit A's ORM model is incomplete.
As for avoiding defining unwanted entity type registration among
persistence units with a common persistence unit root, either going
exclude-unlisted-classes or xml-metadata-complete is really the way to go
if you do not want to repackage your class files.
* - some JPA implementations allow for such mashing, but I'm limiting the
conversation to the letter of the JPA Specification.
Best regards,
Jody Grassel
WebSphere JPA Development, Support, and Testing
From: <gchauvet_at_zatarox.com>
To: users_at_jpa-spec.java.net
Date: 03/20/2017 03:59 AM
Subject: [jpa-spec users] Persistence unit dependencies
Hello everyone,
Since some weeks, I'm facing to a JPA case :
I have 2 persistant units (A & B). Persistant unit A have 40 tables,
persistant unit B have 30 tables.
But A depends of a table in B, through an unidirectinal navigation.
What is the best approach for this case ?
My current fix is to add
<exclude-unlisted-classes>false</exclude-unlisted-classes> to
persistant unit A, but it is a little bit "ugly" (behavior of shared
entities between the 2 PU)
Regards,