OpenJPA Maven Plugin

As of this writing the OpenJPA Plugin provides a way to enhance persistence-enabled classes in a project using Maven 2.

Goals Overview

  • openjpa:enhance enhances the persistence-enabled classes in a project.

    OpenJPA PCEnhancer that is invoked by the OpenJPA Maven Plugin's Enhancer Mojo expects the following resources to be present on classpath:

  • META-INF/orm.xml
  • META-INF/persistence.xml, or
  • META-INF/openjpa.xml

    OpenJPA documentation is available here.

Usage

From the command prompt/terminal window.

  • Change directory to the project's root directory.
  • Run the following goal to run OpenJPA PCEnhancer on persistence-enabled classes.
      mvn openjpa:enhance
    

Examples

Below is a simple Mojo configuration example.

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>openjpa-maven-plugin</artifactId>                    
        <configuration>
          <!-- Pass properties to the Plugin here -->     
          <toolProperties>
            <property>
              <name>addDefaultConstructor</name>
              <value>true</value>
            </property>              
            <property>
              <name>enforcePropertyRestrictions</name>
              <value>true</value>
            </property> 
          </toolProperties>
        </configuration>
      </plugin>