How to tune JPAMetaModelEntityProcessor so it doesn't get "Duplicate class" error?
I am trying to use hibernate-jpamodelgen in conjunction with the maven-processor-plugin to create my JPA meta model as part of my Maven build using the configuration from this answer .
However, when I do the build, I get the following error when I try to do mvn clean install
:
[ERROR] C:\Users\ArtB\Documents\code\xxx\target\classes\me\Page_.java:[11,16] error: duplicate class: me.Page_
From some research, it looks like the problem is that the generated metamodel seems to happen twice or something.
If I run clear; mvn clean generate-sources; ls -l target\generated-sources\apt\me
, I only have the file _Page.java
and no other files.
After the phase, the compile
folder target\classes\
just contains \me\_Page.java
... which seems odd since I thought the files .class
should appear in the "\ target \ classes" folder.
I ran the build with debug (i.e. -X
) and saw nothing suspicious.
I doubt this is important, but here are my models.
package me;
@Entity
@Table(name="Pages")
public class Page {
@Id @GeneratedValue
private long id;
private String title;
private Instant lastRetrieved;
private PageCategory category;
private URL source;
@Lob
private String contents;
//hashcode, equals, getters & setters omitted
}
and
package me;
public enum PageCategory {
PRODUCT,
INFO
;
}
source to share
Apparently you don't need a processor plugin. The usual compiler just works. I have commented everything
<!--
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>4.3.6.Final</version>
</dependency>
</dependencies>
</plugin>
-->
Section and it works great ... go figure. My compiler config:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
source to share