Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A Maven 3 plugin for helping out with common JPA project needs.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src scan classpath, when url is empty.
.gitignore Initial revision
LICENSE.txt Wrangling version numbers


This project houses a Maven plugin for performing various tasks to help with JPA-based projects.

Quick Start

Create a persistence.xml to be used for unit testing in src/test/resources/META-INF:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
             xmlns="" xmlns:xsi=""
  <persistence-unit name="test-Hibernate" transaction-type="RESOURCE_LOCAL">

    <!-- This provider is just an example. -->

    <!-- This is where the magic will happen. -->

      <property name="javax.persistence.jdbc.driver" value="TODO: JDBC driver class name goes here" />
      <property name="javax.persistence.jdbc.url" value="TODO: JDBC connection URL for unit tests goes here" />
      <property name="javax.persistence.jdbc.user" value="TODO: unit test database user goes here" />
      <property name="javax.persistence.jdbc.password" value="TODO: unit test database password goes here" />

      <!-- You may of course put any properties you want here -->
      <property name="hibernate.default_schema" value="TODO: default test schema goes here" />
      <property name="" value="true"/>
      <property name="hibernate.show_sql" value="true" />
      <property name="hibernate.format_sql" value="true" />

Ensure that it does not get copied during resource copying. Add this in your pom.xml's <build> section:

    <!-- Whether you want to filter the other test resources is up to you -->

Now set up the jpa-maven-plugin. Place this in your pom.xml's <build>'s <plugins> section:


Finally, make sure that the persistence.xml is copied over, but only after the jpa-maven-plugin has run. Place this IMMEDIATELY BELOW the plugin stanza listed above:

      <id>Copy persistence.xml filtered with generated file</id>

Run mvn clean process-test-classes if you just want to see the effects of the jpa-maven-plugin. Look in your target/test-classes/META-INF directory. You will see a persistence.xml file with all of your entity and mapped superclass and embeddables and id classes listed. Any Maven lifecycle phases that occur before process-test-classes will not be able to use the effects of the jpa-maven-plugin.

More Information

For more information, grab the source to this project, and from the root directory run:

mvn clean install site

Full documentation will be available at target/site/index.html.

Something went wrong with that request. Please try again.