Question

I have a maven-managed project with some modules (with jar package) , each module contains its "persistence.xml" in its META-INF directory.

Another module take responsibilities to package these modules into a war file . But I find no way to "combine" these "persistence.xml" into one file ...

Is it possible ?

Thanks in advanced.

Was it helpful?

Solution

If you know XSLT, you can write a transform to merge the persistence documents. Maven has a plugin for running XSLT (and validationg XML) - xml-maven-plugin

But do you need to do this? Reading here, and here, for example, states that persistence.xml will be picked up from all jars, not just the webapp war. So you should be able to leave persistence.xml in your library jars and the will be used by the webapp.

OTHER TIPS

hi in order to let the server searching for multiple persistence.xml files and configure all persistence units, you have to package this persistence.xml file on EJB JAR file.

Aymen

Another module take responsibilities to package these modules into a war file . But I find no way to "combine" these "persistence.xml" into one file

Why would you like to do this? If you have several JARs that have a persistence.xml, they define very likely different persistence units (A persistence unit defines the set of all classes that are related or grouped by the application and which must be colocated in their mapping to a single database).

Why don't you obtain an EntityManagerFactory for the right persistence unit?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top