| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <!-- Generated by Apache Maven Doxia Site Renderer 1.8.1 from src/site/apt/usage.apt at 06 Sep 2020 22:01 CEST --> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| <title>OpenJPA Maven Plugin – Introduction</title> |
| <style type="text/css" media="all"> |
| @import url("./css/maven-base.css"); |
| @import url("./css/maven-theme.css"); |
| @import url("./css/site.css"); |
| </style> |
| <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" /> |
| <meta name="author" content="Rahul Thakur, Mark Struberg" /> |
| <meta name="date" content="November 29, 2010" /> |
| <meta http-equiv="Content-Language" content="en" /> |
| |
| </head> |
| <body class="composite"> |
| <div id="banner"> |
| <div id="bannerLeft"> |
| OpenJPA |
| </div> |
| <div class="clear"> |
| <hr/> |
| </div> |
| </div> |
| <div id="breadcrumbs"> |
| <div class="xleft"> |
| <span id="publishDate">Last Published: 06 Sep 2020 22:01 CEST</span> |
| | <span id="projectVersion">Version: 3.1.3-SNAPSHOT</span> |
| </div> |
| <div class="xright"> </div> |
| <div class="clear"> |
| <hr/> |
| </div> |
| </div> |
| <div id="leftColumn"> |
| <div id="navcolumn"> |
| <h5>Overview</h5> |
| <ul> |
| <li class="none"><a href="index.html" title="Introduction">Introduction</a></li> |
| <li class="none"><strong>Usage</strong></li> |
| <li class="none"><a href="plugin-info.html" title="Goals">Goals</a></li> |
| </ul> |
| <h5>Examples</h5> |
| <ul> |
| <li class="none"><a href="examples/enhance.html" title="Enhance">Enhance</a></li> |
| <li class="none"><a href="examples/sql.html" title="SQL">SQL</a></li> |
| <li class="none"><a href="examples/schema.html" title="Schema">Schema</a></li> |
| <li class="none"><a href="examples/testenhance.html" title="TestEnhance">TestEnhance</a></li> |
| </ul> |
| <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy"> |
| <img class="poweredBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /> |
| </a> |
| </div> |
| </div> |
| <div id="bodyColumn"> |
| <div id="contentBox"> |
| <div class="section"> |
| <h2><a name="OpenJPA_Maven_Plugin"></a>OpenJPA Maven Plugin</h2> |
| <p>As of this writing the OpenJPA Plugin provides 3 goals to cope with persistence-enabled classes in a project using Maven 2.</p> |
| <div class="section"> |
| <h3><a name="Goals_Overview"></a>Goals Overview</h3> |
| <ul> |
| <li><tt>openjpa:enhance</tt> enhances the persistence-enabled classes in a project.</li> |
| <li><tt>openjpa:test-enhance</tt> enhances the persistence-enabled test classes in a project. This is typically bound to the process-test-classes phase.</li> |
| <li><tt>openjpa:sql</tt> creates a file which contains the SQL statements for creating or updating the database or directly create the schema in the database.</li> |
| <li><tt>openjpa:schema</tt> create the schema mapping XML file |
| <p>All these OpenJPA Mojos expect the following resources to be present on classpath:</p></li> |
| <li><tt>META-INF/persistence.xml</tt>, or</li> |
| <li><tt>META-INF/openjpa.xml</tt> |
| <p>OpenJPA documentation is available <a class="externalLink" href="http://openjpa.apache.org/documentation.html">here</a>.</p></li></ul></div> |
| <div class="section"> |
| <h3><a name="Examples"></a>Examples</h3> |
| <p>Below is an OpenJPA plugin configuration example.</p> |
| <div class="source"> |
| <pre> <plugin> |
| <groupId>org.apache.openjpa</groupId> |
| <artifactId>openjpa-maven-plugin</artifactId> |
| <version>1.2</version> |
| <configuration> |
| <includes>com/myproject/entities/**/*.class</includes> |
| <addDefaultConstructor>true</addDefaultConstructor> |
| <enforcePropertyRestrictions>true</enforcePropertyRestrictions> |
| |
| <!-- Pass additional properties to the Plugin here --> |
| <toolProperties> |
| <property> |
| <name>directory</name> |
| <value>otherdirectoryvalue</value> |
| </property> |
| </toolProperties> |
| |
| </configuration> |
| <executions> |
| <execution> |
| <id>enhancer</id> |
| <phase>process-classes</phase> |
| <goals> |
| <goal>enhance</goal> |
| </goals> |
| </execution> |
| </executions> |
| |
| </plugin></pre></div> |
| <ul> |
| <li>You don't have to explicitly specify an OpenJPA dependency in the dependencies section of the plugin! Follow the following guide to use this plugin with <a href="#examplesolder_versions.html">older OpenJPA versions</a>.</li> |
| <li>The <tt>openjpa:enhance</tt> mojo will automatically be called in the <tt>process-classes</tt> phase. |
| <p>From the command prompt/terminal window.</p></li> |
| <li>Change directory to the project's root directory.</li> |
| <li>Run the following goal to run OpenJPA PCEnhancer on persistence-enabled classes manually. |
| <div> |
| <pre> mvn openjpa:enhance</pre></div></li> |
| <li>Run the following goal to run OpenJPA MappingTool for creating the database creation SQL statements for all persistence-enabled classes manually. |
| <div> |
| <pre> mvn openjpa:sql</pre></div></li> |
| <li>Run the following goal to run OpenJPA MappingTool for creating the schema mapping XML file for all persistence-enabled classes manually. |
| <div> |
| <pre> mvn openjpa:schema</pre></div></li></ul></div></div> |
| </div> |
| </div> |
| <div class="clear"> |
| <hr/> |
| </div> |
| <div id="footer"> |
| <div class="xright"> |
| Copyright © 2011–2020 <a href="http://www.apache.org">Apache Software Foundation</a>. |
| All rights reserved. </div> |
| <div class="clear"> |
| <hr/> |
| </div> |
| </div> |
| </body> |
| </html> |