4

In a single Mysql database installation I can create different databases with cross-database relationships. My goal is, for example, to use relationships between people on database A and adresses on database B. It seems that EclipseLink has recently added support for such cases Composite persistence unit

Unfortunately more exhaustive examples are hard to find and above all the Composite persistence unit merges persistence.xml files from different jar. In the project I'm currently working on I don't have classes and entities divided in different jars based on the database they refer to. Frankly, watching the documentation on Eclipselink, I cannot figure out the real effort to make the code compliant with what Composite persistence unit requires. Do you have any experience with it ? Are there alternative ways ?

Thanks Filippo

1 Answer 1

3

Are you databases different databases or just different schemas on the same database?

If the are just different schemas, then you don't need composite persistence units, just set the schema in the @Table.

For different databases you can use composite persistence units, the documentation is here,

http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Composite_Persistence_Units

You don't need to have all of the persistence unit classes in the jars (although that is the easiest way to do it. You could just have all of the classes in the root jar, and list the classes in the persistence.xml, and on have the composite persistence.xml in the composite jars.

Sign up to request clarification or add additional context in comments.

1 Comment

Effectively I have different schemas inside the same database, so thanks for your note on annotations. By the way can you clarify the last part, please ? Can you provide a very simplified example of what to put inside jars ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.