I have a dependency library in my Maven project. This library contains JPA2 entities. Only models from entities in root project are generated during the build process, but not models from entities from libraries. I have tried eclipse link generator (CanonicalModelProcessor) and hibernate generator (JPAMetaModelEntityProcessor) I was not able to find any configuration parameters that would include also project dependencies to metamodel generation. I failed to find anything relevant searching web too. I have also tried to manually name all entities (including library entities) in persistence-unit in persistence.xml via class tags
<class>com.example.project.domain.CustomEntity</class>
and also tried to turn on automatic discovery via
<exclude-unlisted-classes>false</exclude-unlisted-classes>
Nothing helped. Just to list all details, I am using Netbeans 8.0.2 and project is set as Java 7 and J2EE7. Bellow are my pom examples for both generators.
Hibernate:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<annotationProcessors>
<annotationProcessor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</annotationProcessor>
</annotationProcessors>
<debug>true</debug>
<optimize>true</optimize>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<AaddGeneratedAnnotation>true</AaddGeneratedAnnotation>
<Adebug>true</Adebug>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
<outputDirectory>${project.build.directory}/generated-sources/meta-model</outputDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>4.3.8.Final</version>
<optional>true</optional>
</dependency>
</dependencies>
</plugin>
Eclipselink:
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>eclipselink-jpa-metamodel</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor</processor>
</processors>
<outputDirectory>${project.build.directory}/generated-sources/meta-model</outputDirectory>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>org.eclipse.persistence.jpa.modelgen.processor</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
</plugin>
Looks like Neil Stockton is right. I have found two possible solutions to this problem:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<excludes>
<exclude>**/persistence.xml</exclude>
</excludes>
</configuration>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With