I'm trying to use DRY in my persistence.xml file in different persistence units.
I have the following persistence.xml
(it's just one file):
<persistence-unit name="siteAPU" transaction-type="JTA">
<jta-data-source>java:/siteADS</jta-data-source>
<class>package.name.Subs</class>
<class>package.name.SubsRef</class>
<class>package.name.SubsLoc</class>
...
<persistence-unit name="siteBPU" transaction-type="JTA">
<jta-data-source>java:/siteBDS</jta-data-source>
<class>package.name.Subs</class>
<class>package.name.SubsRef</class>
<class>package.name.SubsLoc</class>
...
You can see I have two different persistence units and I have the same classes being persisted.
Is there a way I can programmatically generate the persistence.xml
file and don't repeat the content inside each persistence unit?
create a orm file:
Inside the ORM file you will write the entities.
There is a sample here: https://github.com/uaihebert/uaicriteria/blob/master/src/test/resources/orm.xml