Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>REVISED (March/2014)</h2> <p>Please take a look at <a href="http://jinahya.wordpress.com/2014/03/29/jpa-metamodels-with-maven/">jpa-metamodels-with-maven</a></p> <h3>Hibernate</h3> <p>Using Hibernate is most recommended.</p> <p>(<em>I'm not judging any features/functions/usabilities/stabilites on those implementations. And the above statement is only focused in maven usage that I constructed.</em>)</p> <pre class="lang-xml prettyprint-override"><code>&lt;plugin&gt; &lt;groupId&gt;org.bsc.maven&lt;/groupId&gt; &lt;artifactId&gt;maven-processor-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;process&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;process&lt;/goal&gt; &lt;/goals&gt; &lt;phase&gt;generate-sources&lt;/phase&gt; &lt;configuration&gt; &lt;processors&gt; &lt;processor&gt;org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor&lt;/processor&gt; &lt;/processors&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.hibernate&lt;/groupId&gt; &lt;artifactId&gt;hibernate-jpamodelgen&lt;/artifactId&gt; &lt;version&gt;4.3.4.Final&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;/plugin&gt; </code></pre> <h3>OpenJPA</h3> <p>OpenJPA seems require additional element <code>&lt;openjpa.metamodel&gt;true&lt;openjpa.metamodel&gt;</code>.</p> <pre class="lang-xml prettyprint-override"><code>&lt;plugin&gt; &lt;groupId&gt;org.bsc.maven&lt;/groupId&gt; &lt;artifactId&gt;maven-processor-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;process&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;process&lt;/goal&gt; &lt;/goals&gt; &lt;phase&gt;generate-sources&lt;/phase&gt; &lt;configuration&gt; &lt;processors&gt; &lt;processor&gt;org.apache.openjpa.persistence.meta.AnnotationProcessor6&lt;/processor&gt; &lt;/processors&gt; &lt;optionMap&gt; &lt;openjpa.metamodel&gt;true&lt;/openjpa.metamodel&gt; &lt;/optionMap&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.apache.openjpa&lt;/groupId&gt; &lt;artifactId&gt;openjpa&lt;/artifactId&gt; &lt;version&gt;2.3.0&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;/plugin&gt; </code></pre> <h3>EclipseLink</h3> <p>EclipseLink requires <code>persistence.xml</code>.</p> <pre class="lang-xml prettyprint-override"><code>&lt;plugin&gt; &lt;groupId&gt;org.bsc.maven&lt;/groupId&gt; &lt;artifactId&gt;maven-processor-plugin&lt;/artifactId&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;process&lt;/id&gt; &lt;goals&gt; &lt;goal&gt;process&lt;/goal&gt; &lt;/goals&gt; &lt;phase&gt;generate-sources&lt;/phase&gt; &lt;configuration&gt; &lt;processors&gt; &lt;processor&gt;org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor&lt;/processor&gt; &lt;/processors&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;dependencies&gt; &lt;dependency&gt; &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt; &lt;artifactId&gt;org.eclipse.persistence.jpa.modelgen.processor&lt;/artifactId&gt; &lt;version&gt;2.5.1&lt;/version&gt; &lt;/dependency&gt; &lt;/dependencies&gt; &lt;/plugin&gt; </code></pre> <p><strong>========================================</strong></p> <p>For Apache Maven users,</p> <p>Following simple configuration seems work. (<strong>with old maven-compiler-plugin; updated.</strong>)</p> <pre class="lang-xml prettyprint-override"><code>&lt;!-- This method doesn't work with newest maven-compiler-plugin --&gt; &lt;!-- But if it's ok to work with old maven-compiler-plugin --&gt; &lt;!-- This is the best method --&gt; &lt;!-- There is no other required configurations --&gt; &lt;!-- We don't even require to config any processor names --&gt; &lt;project&gt; &lt;build&gt; &lt;extensions&gt; &lt;extension&gt; &lt;groupId&gt;org.hibernate&lt;/groupId&gt; &lt;artifactId&gt;hibernate-jpamodelgen&lt;/artifactId&gt; &lt;version&gt;1.3.0.Final&lt;/version&gt; &lt;/extension&gt; &lt;/extensions&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;2.5.1&lt;/version&gt; &lt;!-- this is critical --&gt; &lt;configuration&gt; &lt;source&gt;1.6&lt;/source&gt; &lt;target&gt;1.6&lt;/target&gt; &lt;/configuration&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre> <p>you can run it with "mvn compiler:compile"</p> <p><strong>UPDATE</strong></p> <p>Note that this method works only with those old maven-compiler-plugin. Check the version in code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload