3

I am trying to use the hibernate-jpamodelgen in conjunction with the maven-processor-plugin to generate 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 a mvn clean install:

[ERROR] C:\Users\ArtB\Documents\code\xxx\target\classes\me\Page_.java:[11,16] error: duplicate class: me.Page_  

From some investigation it looks like the issue is that the generated meta-model seems to occur twice or something.

If I run clear; mvn clean generate-sources; ls -l target\generated-sources\apt\me I have just the file _Page.javaand no other files.

After the compile phase the target\classes\ folder just contains \me\_Page.java ... which seems strange since I thought .class files should appear in the "\target\classes" folder.

I ran the build with debug (ie -X) and saw nothing suspicious.


I doubt it matters, 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
    ;
}
Community
  • 1
  • 1
Sled
  • 18,541
  • 27
  • 119
  • 168

1 Answers1

9

Apparently, you don't need the processor plugin. Just the regular compiler works. I commented out the entire

<!--
<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 fine... go figure. My compiler configuration is:

<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>
Sled
  • 18,541
  • 27
  • 119
  • 168
  • What about the Compile-time vs Runtime advantage mentioned here: http://stackoverflow.com/questions/25014572/advantage-of-using-jpametamodelentityprocessor ? – AWhitford Jan 13 '15 at 04:26
  • @AWhitford that seems like another question altogether. – Sled Jan 13 '15 at 15:14