I have an EJB module M, contained in an EAR module.
M has a dependency on a jar file data-model.jar, installed as a JBoss module and correctly loaded using the jboss-deployment-structure.xml file.
The module works without any problems, but I cannot help adding every single entity as a <class>
tag in persistence.xml.
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="persistenceUnitName" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/datasource</jta-data-source>
<class>com.bla.persistence.entity.EntityOne</class>
<class>com.bla.persistence.entity.EntityTwo</class>
...
So the question is: is there a way to specify the persistent managed classes associated with a persistence unit loading them from a JBoss module, without adding them all as class tags in persistence.xml?
By default the persistence unit is associated with the annotated managed persistence classes contained in the root of the persistence unit (e.d. the jar file the persistence.xml is in) (docs).
I have tried adding:
<exclude-unlisted-classes>false</exclude-unlisted-classes>
but it does not change anything (I have read that Java EE applications use this value as a default anyway).
I could also use:
<jar-file>?</jar-file>
but I don't know how to refer to the JBoss module (and hardcoding the name of the module's file seems a very bad practice to me).
Working with:
- JBoss EAP 6.4
- Hibernate 4.2.18
- JPA 2