METAGEN-27
This commit is contained in:
parent
22db734897
commit
67a89cb2d7
|
@ -243,13 +243,13 @@
|
||||||
<autoVersionSubmodules>true</autoVersionSubmodules>
|
<autoVersionSubmodules>true</autoVersionSubmodules>
|
||||||
<allowTimestampedSnapshots>true</allowTimestampedSnapshots>
|
<allowTimestampedSnapshots>true</allowTimestampedSnapshots>
|
||||||
<remoteTagging>true</remoteTagging>
|
<remoteTagging>true</remoteTagging>
|
||||||
<goals>package deploy javadoc:javadoc org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.0:resources org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.0:generate assembly:assembly</goals>
|
<goals>package deploy javadoc:javadoc org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.1:resources org.jboss.maven.plugins:maven-jdocbook-plugin:2.2.1:generate assembly:assembly</goals>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jboss.maven.plugins</groupId>
|
<groupId>org.jboss.maven.plugins</groupId>
|
||||||
<artifactId>maven-jdocbook-plugin</artifactId>
|
<artifactId>maven-jdocbook-plugin</artifactId>
|
||||||
<version>2.2.0</version>
|
<version>2.2.1</version>
|
||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -18,159 +18,145 @@
|
||||||
-->
|
-->
|
||||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
||||||
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
||||||
<!ENTITY versionNumber "1.0.0">
|
<!ENTITY version "WORKING">
|
||||||
<!ENTITY copyrightYear "2010">
|
<!ENTITY copyrightYear "2010">
|
||||||
<!ENTITY copyrightHolder "Red Hat Middleware, LLC.">
|
<!ENTITY copyrightHolder "Red Hat Inc.">
|
||||||
|
<!ENTITY jpa2Ref '<citation><xref linkend="JPA2"/></citation>'>
|
||||||
|
<!ENTITY jsr269Ref '<citation><xref linkend="JSR_269"/></citation>'>
|
||||||
]>
|
]>
|
||||||
<book lang="en">
|
<book lang="en">
|
||||||
<bookinfo>
|
<bookinfo>
|
||||||
<title>Hibernate Metamodel Generator</title>
|
<title>Hibernate Metamodel Generator</title>
|
||||||
|
|
||||||
<subtitle>JPA 2 Static Metamodel Annotation Processor</subtitle>
|
<subtitle>JPA 2 Static Metamodel Annotation Processor</subtitle>
|
||||||
|
|
||||||
<subtitle>Reference Guide</subtitle>
|
<subtitle>Reference Guide</subtitle>
|
||||||
|
<releaseinfo>&version;</releaseinfo>
|
||||||
<releaseinfo>&versionNumber;</releaseinfo>
|
<productnumber>&version;</productnumber>
|
||||||
|
|
||||||
<productnumber>&versionNumber;</productnumber>
|
|
||||||
|
|
||||||
<copyright>
|
<copyright>
|
||||||
<year>©rightYear;</year>
|
<year>©rightYear;</year>
|
||||||
|
|
||||||
<holder>©rightHolder;</holder>
|
<holder>©rightHolder;</holder>
|
||||||
</copyright>
|
</copyright>
|
||||||
</bookinfo>
|
</bookinfo>
|
||||||
|
<toc/>
|
||||||
<toc></toc>
|
|
||||||
|
|
||||||
<chapter id="introduction">
|
<chapter id="introduction">
|
||||||
<title>Introduction</title>
|
<title>Introduction</title>
|
||||||
|
|
||||||
<section id="whatisit" revision="1">
|
<section id="whatisit" revision="1">
|
||||||
<title>What is it about?</title>
|
<title>What is it about?</title>
|
||||||
|
<para>JPA 2 defines a new typesafe <classname>Criteria</classname> API which allows criteria
|
||||||
<para>JPA 2 defines a new typesafe <classname>Criteria</classname> API
|
queries to be constructed in a strongly-typed manner, using metamodel objects to provide
|
||||||
which allows criteria queries to be constructed in a strongly-typed
|
type safety. For developers it is important that the task of the metamodel generation can be
|
||||||
manner, using metamodel objects to provide type safety. This type saftey
|
automated. Hibernate Static Metamodel Generator is an annotation processor based on the
|
||||||
is of course only useful for developers if the task of the metamodel
|
&jsr269Ref; with the task of creating JPA 2 static metamodel classes. The following example
|
||||||
generation can be automated. Hibernate Static Metamodel Generator is an
|
show two JPA 2 entities <classname>Order</classname> and <classname>Item</classname>,
|
||||||
annotation processor based on the annotation processing API defined in
|
together with the metamodel class <classname>Order_</classname> and a typesafe query.</para>
|
||||||
<ulink url="???">JSR 269</ulink> with the task of creating the static
|
|
||||||
metamodel classes for JPA 2 entities. The following examples show a
|
|
||||||
managed JPA 2 entity, together with is metamodel class and an example
|
|
||||||
typesafe query.</para>
|
|
||||||
|
|
||||||
<example id="jpa2-entity-example">
|
<example id="jpa2-entity-example">
|
||||||
<title>JPA 2 annotated entity</title>
|
<title>JPA 2 annotated entities <classname>Order</classname> and
|
||||||
|
<classname>Item</classname></title>
|
||||||
<programlisting>@Entity public class Order {
|
<programlisting>
|
||||||
|
@Entity
|
||||||
|
public class Order {
|
||||||
@Id
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
Integer id;
|
Integer id;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
Customer customer;
|
Customer customer;
|
||||||
|
|
||||||
@OneToMany
|
@OneToMany
|
||||||
Set<Item> items;
|
Set<Item> items;
|
||||||
BigDecimal totalCost;
|
BigDecimal totalCost;
|
||||||
|
|
||||||
// standard setter/getter methods
|
// standard setter/getter methods
|
||||||
...
|
...
|
||||||
}</programlisting>
|
}
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Item {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
Integer id;
|
||||||
|
|
||||||
|
int quantity;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
Order order;
|
||||||
|
|
||||||
|
// standard setter/getter methods
|
||||||
|
...
|
||||||
|
}
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
|
||||||
<example id="metamodel-class-example">
|
<example id="metamodel-class-example">
|
||||||
<title>Matching metamodel class for entity
|
<title>Metamodel class <classname>Order_</classname></title>
|
||||||
<classname>Order</classname></title>
|
<programlisting>
|
||||||
|
@StaticMetamodel(Order.class)
|
||||||
<programlisting>@StaticMetamodel(Order.class)
|
|
||||||
public class Order_ {
|
public class Order_ {
|
||||||
public static volatile SingularAttribute<Order, Integer> id;
|
public static volatile SingularAttribute<Order, Integer> id;
|
||||||
public static volatile SingularAttribute<Order, Customer> customer;
|
public static volatile SingularAttribute<Order, Customer> customer;
|
||||||
public static volatile SetAttribute<Order, Item> items;
|
public static volatile SetAttribute<Order, Item> items;
|
||||||
public static volatile SingularAttribute<Order, BigDecimal> totalCost;
|
public static volatile SingularAttribute<Order, BigDecimal> totalCost;
|
||||||
}</programlisting>
|
}
|
||||||
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
<example id="criteria-example">
|
||||||
<example id="criteria-example" label="">
|
<title>Typesafe citeria query</title>
|
||||||
<title>Example of typesafe query using the metamodel class
|
<programlisting>
|
||||||
<classname>Order_</classname></title>
|
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||||
|
|
||||||
<programlisting>CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
|
||||||
CriteriaQuery<Order> cq = cb.createQuery(Order.class);
|
CriteriaQuery<Order> cq = cb.createQuery(Order.class);
|
||||||
SetJoin<Order, Item> itemNode = cq.from(Order.class).join(Order_.orderItems);
|
SetJoin<Order, Item> itemNode = cq.from(Order.class).join(Order_.items);
|
||||||
cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
||||||
</programlisting>
|
</programlisting>
|
||||||
</example>
|
</example>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>Canonical Metamodel</title>
|
<title>Canonical Metamodel</title>
|
||||||
|
<para>The structure of the metamodel classes is described in the &jpa2Ref;, but for completeness the definition
|
||||||
<para>The structure of the metamodel classes is described in the <ulink
|
is repeated in the following paragraphs. Feel free to skip ahead to <xref
|
||||||
url="http://jcp.org/en/jsr/detail?id=317">JPA 2 specification</ulink>
|
linkend="chapter-usage"/> if you are not interested into the gory details.</para>
|
||||||
and its definition is included for completeness in the following
|
<para>The annotation processor produces for every managed class in the persistence unit a
|
||||||
paragraphs . Feel free to skip ahead to <xref linkend="chapter-usage" />
|
metamodel class based on these rules:</para>
|
||||||
if you are not interested into the gory details.</para>
|
|
||||||
|
|
||||||
<para>The annotation processor produces for every managed class in the
|
|
||||||
persistence unit a metamodel class based on these rules:</para>
|
|
||||||
|
|
||||||
<para><itemizedlist>
|
<para><itemizedlist>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>For each managed class <classname>X</classname> in package
|
<para>For each managed class <classname>X</classname> in package p, a metamodel class
|
||||||
p, a metamodel class <classname>X_</classname> in package p is
|
<classname>X_</classname> in package p is created.</para>
|
||||||
created.</para>
|
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>The name of the metamodel class is derived from the name of
|
<para>The name of the metamodel class is derived from the name of the managed class by
|
||||||
the managed class by appending "_" to the name of the managed
|
appending "_" to the name of the managed class.</para>
|
||||||
class.</para>
|
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>The metamodel class <classname>X_</classname> must be
|
<para>The metamodel class <classname>X_</classname> must be annotated with the
|
||||||
annotated with the
|
<classname>javax.persistence.StaticMetamodel</classname> annotation.</para>
|
||||||
<classname>javax.persistence.StaticMetamodel</classname>
|
|
||||||
annotation.</para>
|
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>If class <classname>X</classname> extends another class
|
<para>If class <classname>X</classname> extends another class <classname>S</classname>,
|
||||||
<classname>S</classname>, where <classname>S</classname> is the
|
where <classname>S</classname> is the most derived managed class (i.e., entity or
|
||||||
most derived managed class (i.e., entity or mapped superclass)
|
mapped superclass) extended by <classname>X</classname>, then class
|
||||||
extended by <classname>X</classname>, then class
|
<classname>X_</classname> must extend class <classname>S_</classname>, where
|
||||||
<classname>X_</classname> must extend class
|
<classname>S_</classname> is the metamodel class created for
|
||||||
<classname>S_</classname>, where <classname>S_</classname> is the
|
<classname>S</classname>.</para>
|
||||||
metamodel class created for <classname>S</classname>.</para>
|
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>For every persistent non-collection-valued attribute y
|
<para>For every persistent non-collection-valued attribute y declared by class
|
||||||
declared by class <classname>X</classname>, where the type of y is
|
<classname>X</classname>, where the type of y is <classname>Y</classname>, the
|
||||||
<classname>Y</classname>, the metamodel class must contain a
|
metamodel class must contain a declaration as follows:
|
||||||
declaration as follows: <programlisting>public static volatile SingularAttribute<X, Y> y;</programlisting></para>
|
<programlisting>public static volatile SingularAttribute<X, Y> y;</programlisting></para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>For every persistent collection-valued attribute z declared
|
<para>For every persistent collection-valued attribute z declared by class
|
||||||
by class <classname>X</classname>, where the element type of z is
|
<classname>X</classname>, where the element type of z is <classname>Z</classname>,
|
||||||
<classname>Z</classname>, the metamodel class must contain a
|
the metamodel class must contain a declaration as follows:<itemizedlist>
|
||||||
declaration as follows:<itemizedlist>
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>if the collection type of z is java.util.Collection,
|
<para>if the collection type of z is java.util.Collection, then
|
||||||
then <programlisting>public static volatile CollectionAttribute<X, Z> z;</programlisting></para>
|
<programlisting>public static volatile CollectionAttribute<X, Z> z;</programlisting></para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>if the collection type of z is java.util.Set, then
|
<para>if the collection type of z is java.util.Set, then
|
||||||
<programlisting>public static volatile SetAttribute<X, Z> z;</programlisting></para>
|
<programlisting>public static volatile SetAttribute<X, Z> z;</programlisting></para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>if the collection type of z is java.util.List, then
|
<para>if the collection type of z is java.util.List, then
|
||||||
<programlisting>public static volatile ListAttribute<X, Z> z;</programlisting></para>
|
<programlisting>public static volatile ListAttribute<X, Z> z;</programlisting></para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>if the collection type of z is java.util.Map, then
|
<para>if the collection type of z is java.util.Map, then
|
||||||
<programlisting>public static volatile MapAttribute<X, K, Z> z;</programlisting>
|
<programlisting>public static volatile MapAttribute<X, K, Z> z;</programlisting>
|
||||||
|
@ -179,62 +165,49 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
||||||
</itemizedlist></para>
|
</itemizedlist></para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>Import statements must be included for the needed
|
</itemizedlist>Import statements must be included for the needed
|
||||||
<classname>javax.persistence.metamodel</classname> types as appropriate
|
<classname>javax.persistence.metamodel</classname> types as appropriate and all classes
|
||||||
and all classes <classname>X</classname>, <classname>Y</classname>,
|
<classname>X</classname>, <classname>Y</classname>, <classname>Z</classname>, and
|
||||||
<classname>Z</classname>, and <classname>K</classname>.</para>
|
<classname>K</classname>.</para>
|
||||||
</section>
|
</section>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
||||||
<chapter id="chapter-usage">
|
<chapter id="chapter-usage">
|
||||||
<title>Usage</title>
|
<title>Usage</title>
|
||||||
|
|
||||||
<para>The jar file for the annotation processor can be found in the <ulink
|
<para>The jar file for the annotation processor can be found in the <ulink
|
||||||
url="http://repository.jboss.com/">JBoss Maven repository</ulink>
|
url="http://repository.jboss.com/">JBoss Maven repository</ulink> using <xref
|
||||||
under:</para>
|
linkend="maven-dependency"/>.</para>
|
||||||
|
<example id="maven-dependency">
|
||||||
<example id="maven-dependency" label="">
|
<title>Maven dependency </title>
|
||||||
<title>Maven dependency for Hibernate Static Metamodel Generator</title>
|
|
||||||
|
|
||||||
<programlisting><dependency>
|
<programlisting><dependency>
|
||||||
<groupId>org.hibernate</groupId>
|
<groupId>org.hibernate</groupId>
|
||||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
</dependency></programlisting>
|
</dependency></programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
<para>Alternatively, a full distribution package can be downloaded from <ulink
|
||||||
<para>Alternatively, a full distribution package can be downloaded from
|
url="http://sourceforge.net/projects/hibernate">SourceForge</ulink>.</para>
|
||||||
<ulink url="http://sourceforge.net/">SourceForge</ulink>.</para>
|
<para>In most cases the annotation processor will automatically run provided
|
||||||
|
the processor jar is added to the classpath and a JDK 6 is used. This happens due to <ulink
|
||||||
<para>In most cases the annotation processor will automatically run
|
|
||||||
provided a JDK version 6i used and the jar file is added to the classpath.
|
|
||||||
This happens due to <ulink
|
|
||||||
url="http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Service%20Provider">Java's
|
url="http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Service%20Provider">Java's
|
||||||
Service Provider</ulink> contract and the fact the the Hibernate Static
|
Service Provider</ulink> contract and the fact the the Hibernate Static Metamodel Generator
|
||||||
Metamodel Generator jar files contains the file
|
jar files contains the file <classname>javax.annotation.processing.Processor</classname> in
|
||||||
<classname>javax.annotation.processing.Processor</classname> in the
|
the <filename>META-INF/services</filename> directory. The fully qualified name of the
|
||||||
<filename>META-INF/services</filename> directory. The fully qualified name
|
processor itself is:
|
||||||
of the processor itself is:
|
<classname>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</classname>. <note>
|
||||||
<classname>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</classname>.
|
|
||||||
<note>
|
|
||||||
<para>The use of a Java 6 compiler is a prerequisite.</para>
|
<para>The use of a Java 6 compiler is a prerequisite.</para>
|
||||||
</note></para>
|
</note></para>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>Usage from the command line</title>
|
<title>Usage from the command line</title>
|
||||||
|
<section id="usage-ant" revision="1">
|
||||||
<para><section id="usage-ant" revision="1">
|
|
||||||
<title>Usage with Ant</title>
|
<title>Usage with Ant</title>
|
||||||
</section>As mentioned before, the annotation processor will run
|
<para>As mentioned before, the annotation processor will run automatically each time the
|
||||||
automatically each time the Java compiler is called - provided the jar
|
Java compiler is called, provided the jar file is on the classpath. Sometimes, however, it is
|
||||||
file is on the classpath. Somtimes it is, however, useful to control the
|
useful to control the annotation processing in more detail, for example if you
|
||||||
annotation processing in more detail, for example if you exclusively
|
exclusively want to run the processor without compiling any other source files. <xref
|
||||||
want to run the processor without compiling any other source files.
|
linkend="javac-task-example"/> shows how Ant's <ulink
|
||||||
<xref linkend="javac-task-example" /> shows how the <ulink
|
url="http://ant.apache.org/manual/CoreTasks/javac.html">Javac Task</ulink> can be
|
||||||
url="http://ant.apache.org/manual/CoreTasks/javac.html">Ant Javac
|
configured to just run annotation processing.</para>
|
||||||
Task</ulink> can be configured to just run annotation
|
<example id="javac-task-example">
|
||||||
processing.<example id="javac-task-example">
|
<title>Javac Task configuration</title>
|
||||||
<title>Ant Javac Task configuration</title>
|
|
||||||
|
|
||||||
<programlisting><javac srcdir="${src.dir}"
|
<programlisting><javac srcdir="${src.dir}"
|
||||||
destdir="${target.dir}"
|
destdir="${target.dir}"
|
||||||
failonerror="false"
|
failonerror="false"
|
||||||
|
@ -242,24 +215,24 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
||||||
classpath="${classpath}">
|
classpath="${classpath}">
|
||||||
<emphasis role="bold"><compilerarg value="-proc:only"/></emphasis>
|
<emphasis role="bold"><compilerarg value="-proc:only"/></emphasis>
|
||||||
</javac></programlisting>
|
</javac></programlisting>
|
||||||
</example>The option <emphasis>-proc:only</emphasis> instructs the
|
</example>
|
||||||
compiler to just run the annotation processing. You can also completely
|
<para>The option <emphasis>-proc:only</emphasis> instructs the compiler to just run the
|
||||||
disable processing by specifying <emphasis>-proc:none</emphasis>.<tip>
|
annotation processing. You can also completely disable processing by specifying
|
||||||
<para>Run <literal>'javac -help'</literal> to see which other
|
<emphasis>-proc:none</emphasis>.</para>
|
||||||
annotation processor relevant options can be specified.</para>
|
<tip>
|
||||||
</tip><section revision="1">
|
<para>Run <literal>'javac -help'</literal> to see which other annotation processor
|
||||||
|
relevant options can be specified.</para>
|
||||||
|
</tip>
|
||||||
|
</section>
|
||||||
|
<section revision="1">
|
||||||
<title>Usage with Maven</title>
|
<title>Usage with Maven</title>
|
||||||
</section>There are several ways of running the annotation processor
|
<para>There are several ways of running the annotation processor as part of a Maven build.
|
||||||
as part of a Maven build. Again, it will automatically run if you are
|
Again, it will automatically run if you are using a JDK 6 compiler and the annotation
|
||||||
using a JDK 6 compiler and the annotation processor jar is on the
|
processor jar is on the classpath. In case you have more than one annotation processors on
|
||||||
classpath. In case you have more than one annotation processors on your
|
your classpath you can explicitly pass the processor option to the compiler plugin:</para>
|
||||||
classpath you can explicitly pass the processor option to the compiler
|
<para>
|
||||||
plugin:</para>
|
<example>
|
||||||
|
<title>Maven compiler plugin configuration - direct execution</title>
|
||||||
<para><example>
|
|
||||||
<title>Maven compiler plugin configuration - direct
|
|
||||||
execution</title>
|
|
||||||
|
|
||||||
<programlisting><plugin>
|
<programlisting><plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
@ -270,22 +243,17 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
||||||
</compilerArguments>
|
</compilerArguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin></programlisting>
|
</plugin></programlisting>
|
||||||
</example></para>
|
</example>
|
||||||
|
</para>
|
||||||
<para>The maven-compiler-plugin approach has the disadvantage that the
|
<para>The maven-compiler-plugin approach has the disadvantage that the maven compiler plugin
|
||||||
maven compiler plugin does currently not allow to specify multiple
|
does currently not allow to specify multiple compiler arguments (<ulink
|
||||||
compiler arguments (<ulink
|
url="http://jira.codehaus.org/browse/MCOMPILER-62">MCOMPILER-62</ulink>) and that
|
||||||
url="http://jira.codehaus.org/browse/MCOMPILER-62">MCOMPILER-62</ulink>)
|
messages from the Messenger API are suppressed (<ulink
|
||||||
and that messages from the Messenger API are suppressed (<ulink
|
url="http://jira.codehaus.org/browse/MCOMPILER-66">MCOMPILER-66</ulink>). A better
|
||||||
url="http://jira.codehaus.org/browse/MCOMPILER-66">MCOMPILER-66</ulink>).
|
approach is to disable annotation processing for the compiler plugin as seen in <xref
|
||||||
A better approach is to disable annotation processing for the compiler
|
linkend="disable-processing-maven-compiler-plugin"/>.</para>
|
||||||
plugin as seen in <xref
|
|
||||||
linkend="disable-processing-maven-compiler-plugin" />.</para>
|
|
||||||
|
|
||||||
<example id="disable-processing-maven-compiler-plugin">
|
<example id="disable-processing-maven-compiler-plugin">
|
||||||
<title>Maven compiler plugin configuration - indirect
|
<title>Maven compiler plugin configuration - indirect execution</title>
|
||||||
execution</title>
|
|
||||||
|
|
||||||
<programlisting><plugin>
|
<programlisting><plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
@ -295,21 +263,15 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin></programlisting>
|
</plugin></programlisting>
|
||||||
</example>
|
</example>
|
||||||
|
<para>Once disabled, the <ulink url="http://code.google.com/p/maven-annotation-plugin/"
|
||||||
<para>Once disabled, the <ulink
|
>maven-annotation-plugin</ulink> for annotation processing (you will need the following
|
||||||
url="http://code.google.com/p/maven-annotation-plugin/">maven-annotation-plugin</ulink>
|
additional maven repositories: <ulink
|
||||||
for annotation processing (you will need the following additional maven
|
url="http://maven-annotation-plugin.googlecode.com/svn/trunk/mavenrepo"
|
||||||
repositories - <ulink
|
>maven-annotation-plugin</ulink> and <ulink
|
||||||
url="http://maven-annotation-plugin.googlecode.com/svn/trunk/mavenrepo">maven-annotation-plugin</ulink>
|
url="http://www.jfrog.org/artifactory/plugins-releases">jfrog</ulink>) can be used. The
|
||||||
and <ulink
|
configuration can be seen in <xref linkend="maven-processor-plugin"/>.</para>
|
||||||
url="http://www.jfrog.org/artifactory/plugins-releases">jfrog</ulink>)
|
|
||||||
can be used. The configuration can be seen in <xref
|
|
||||||
linkend="maven-processor-plugin" />.</para>
|
|
||||||
|
|
||||||
<example id="maven-processor-plugin">
|
<example id="maven-processor-plugin">
|
||||||
<title>Maven compiler plugin configuration with
|
<title>Maven compiler plugin configuration with maven-annotation-plugin</title>
|
||||||
maven-annotation-plugin</title>
|
|
||||||
|
|
||||||
<programlisting><plugin>
|
<programlisting><plugin>
|
||||||
<groupId>org.bsc.maven</groupId>
|
<groupId>org.bsc.maven</groupId>
|
||||||
<artifactId>maven-processor-plugin</artifactId>
|
<artifactId>maven-processor-plugin</artifactId>
|
||||||
|
@ -348,148 +310,134 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
||||||
</plugin></programlisting>
|
</plugin></programlisting>
|
||||||
</example>
|
</example>
|
||||||
</section>
|
</section>
|
||||||
|
</section>
|
||||||
<section>
|
<section>
|
||||||
<title>Usage within the IDE</title>
|
<title>Usage within the IDE</title>
|
||||||
|
<para>Of course you also want to have annotation processing available in your favorite IDE.
|
||||||
<para>Of course you also want to have annotation processing available in
|
The following paragraphs and screenshots show you how to enable the Hibernate Static
|
||||||
your favorite IDE. The following paragraphs and screenshots show you how
|
Metamodel Generator within your IDE.</para>
|
||||||
to enable the Hibernate Static Metamodel Generator within your
|
|
||||||
IDE.</para>
|
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>Idea</title>
|
<title>Idea</title>
|
||||||
|
<para>Intellij Idea contains from version 9.x onwards a specifc configuration section for
|
||||||
<para>Intellij Idea contains from version 9.x onwards a specifc
|
annotation processing under the project settings window. The screenshots show you how to
|
||||||
configuration section for annotation processing under the project
|
configure the Hibernate Static Metamodel Generator.</para>
|
||||||
settings window. The screenshots show you how to configure the
|
|
||||||
Hibernate Static Metamodel Generator.</para>
|
|
||||||
|
|
||||||
<mediaobject>
|
<mediaobject>
|
||||||
<imageobject role="fo">
|
<imageobject role="fo">
|
||||||
<imagedata align="center" contentdepth="" contentwidth="150mm"
|
<imagedata align="center" contentdepth="" contentwidth="150mm"
|
||||||
fileref="idea-annotation-processor-config.png"
|
fileref="idea-annotation-processor-config.png" scalefit=""/>
|
||||||
scalefit="" />
|
|
||||||
</imageobject>
|
</imageobject>
|
||||||
|
|
||||||
<imageobject role="html">
|
<imageobject role="html">
|
||||||
<imagedata depth="" fileref="idea-annotation-processor-config.png"
|
<imagedata depth="" fileref="idea-annotation-processor-config.png" scalefit="1"/>
|
||||||
scalefit="1" />
|
|
||||||
</imageobject>
|
</imageobject>
|
||||||
</mediaobject>
|
</mediaobject>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>Eclipse</title>
|
<title>Eclipse</title>
|
||||||
|
<para>In Eclipse, from the Galileo release onwards, exists an additional configuration
|
||||||
<para>In Eclipse, from the Galileo release onwards, exists an
|
section under Java Compiler. There you can configure all kinds of aspects of annotation
|
||||||
additional configuration section under Java Compiler. There you can
|
processing. Just check the "Enable annotation processing" option, configure the directory
|
||||||
configure all kinds of aspects of annotation processing. Just check
|
for the generated sources and finally add the Hibernate Static Metamodel Generator and JPA
|
||||||
the "Enable annotation processing" option, configure the directory for
|
2 jar files to the factory path.</para>
|
||||||
the generated sources and finally add the Hibernate Static Metamodel
|
|
||||||
Generator and JPA 2 jar files to the factory path.</para>
|
|
||||||
|
|
||||||
<mediaobject>
|
<mediaobject>
|
||||||
<imageobject role="fo">
|
<imageobject role="fo">
|
||||||
<imagedata align="center" contentdepth="" contentwidth="150mm"
|
<imagedata align="center" contentdepth="" contentwidth="150mm"
|
||||||
fileref="eclipse-annotation-processor-config.png"
|
fileref="eclipse-annotation-processor-config.png" scalefit=""/>
|
||||||
scalefit="" />
|
|
||||||
</imageobject>
|
</imageobject>
|
||||||
|
|
||||||
<imageobject role="html">
|
<imageobject role="html">
|
||||||
<imagedata depth=""
|
<imagedata depth="" fileref="eclipse-annotation-processor-config.png" scalefit="1"/>
|
||||||
fileref="eclipse-annotation-processor-config.png"
|
|
||||||
scalefit="1" />
|
|
||||||
</imageobject>
|
</imageobject>
|
||||||
</mediaobject>
|
</mediaobject>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>NetBeans</title>
|
<title>NetBeans</title>
|
||||||
|
<para>Netbeans support for annotation processors is at the time of this wrinting still in
|
||||||
<para>Netbeans support for annotation processors is at the time of
|
the making. Refer to NetBeans issues <ulink
|
||||||
this wrinting still in the making. Refer to NetBeans issues <ulink
|
url="http://www.netbeans.org/issues/show_bug.cgi?id=111065">111065</ulink>, <ulink
|
||||||
url="http://www.netbeans.org/issues/show_bug.cgi?id=111065">111065</ulink>,
|
url="http://www.netbeans.org/issues/show_bug.cgi?id=111293">111293</ulink> and <ulink
|
||||||
<ulink
|
url="http://www.netbeans.org/issues/show_bug.cgi?id=111294">111294</ulink>.</para>
|
||||||
url="http://www.netbeans.org/issues/show_bug.cgi?id=111293">111293</ulink>
|
|
||||||
and <ulink url="???">111294</ulink>.</para>
|
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<title>Processor specific options</title>
|
<title>Processor specific options</title>
|
||||||
|
<para>The Hibernate Static Metamodel Generator accepts a series of custom options which can be
|
||||||
<para>The Hibernate Static Metamodel Generator accepts a series of
|
passed to the processor in the format <literal>-A[property]=[value]</literal>. The supported
|
||||||
custom options which can be passed to the processor in the format
|
properties are:<table>
|
||||||
<literal>-A[property]=[value]</literal>. The supported properties
|
<title>Annotation processor options (passed via -A[property]=[value])</title>
|
||||||
are:<table>
|
|
||||||
<title>Annotation processor options (passed via
|
|
||||||
-A[property]=[value])</title>
|
|
||||||
|
|
||||||
<tgroup cols="2">
|
<tgroup cols="2">
|
||||||
<tbody>
|
<tbody>
|
||||||
<row>
|
<row>
|
||||||
<entry><emphasis role="bold">Option name</emphasis></entry>
|
<entry><emphasis role="bold">Option name</emphasis></entry>
|
||||||
|
<entry><emphasis role="bold">Option value and usage</emphasis></entry>
|
||||||
<entry><emphasis role="bold">Option value and
|
|
||||||
usage</emphasis></entry>
|
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry>debug</entry>
|
<entry>debug</entry>
|
||||||
|
<entry>if set to <literal>true</literal> additional trace information will be
|
||||||
<entry>if set to <literal>true</literal> additional trace
|
outputted by the processor</entry>
|
||||||
information will be outputted by the processor</entry>
|
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry>persistenceXml</entry>
|
<entry>persistenceXml</entry>
|
||||||
|
<entry>Per default the processor looks in <filename>/META-INF</filename> for
|
||||||
<entry>Per default the processor looks in
|
persistence.xml. Specifying this option a <filename>persitence.xml</filename> file
|
||||||
<filename>/META-INF</filename> for persistence.xml. Specifying
|
from a different location can be specified (has to be on the classpath)</entry>
|
||||||
this option a <filename>persitence.xml</filename> file from a
|
|
||||||
different location can be specified (has to be on the
|
|
||||||
classpath)</entry>
|
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry>ormXml</entry>
|
<entry>ormXml</entry>
|
||||||
|
<entry>Allows to specify additional entity mapping files. The specified value for
|
||||||
<entry>Allows to specify additional entity mapping files. The
|
this option is a comma separated string of mapping file names. Even when this
|
||||||
specified value for this option is a comma separated string of
|
option is specified <filename>/META-INF/orm.xml</filename> is implicit.</entry>
|
||||||
mapping file names. Even when this option is specified
|
|
||||||
<filename>/META-INF/orm.xml</filename> is implicit.</entry>
|
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry>lazyXmlParsing</entry>
|
<entry>lazyXmlParsing</entry>
|
||||||
|
<entry>Possible values are <literal>true</literal> or <literal>false</literal>. If
|
||||||
<entry>Possible values are <literal>true</literal> or
|
set to <literal>true</literal> the annotation processor tries to determine whether
|
||||||
<literal>false</literal>. If set to <literal>true</literal>
|
any of the xml files has changed between invocations and if unchanged skips the
|
||||||
the annotation processor tries to determine whether any of the
|
xml parsing. This feature is experimental and contains the risk of wron results in
|
||||||
xml files has changed between invocations and if unchanged
|
some cases of mixed mode configurations. To determine wether a file has been
|
||||||
skips the xml parsing. This feature is experimental and
|
modified a temporary file
|
||||||
contains the risk of wron results in some cases of mixed mode
|
<filename>Hibernate-Static-Metamodel-Generator.tmp</filename> is used. This file
|
||||||
configurations. To determine wether a file has been modified a
|
gets created in the <literal>java.io.tmpdir</literal> directory.</entry>
|
||||||
temporary file
|
|
||||||
<filename>Hibernate-Static-Metamodel-Generator.tmp</filename>
|
|
||||||
is used. This file gets created in the
|
|
||||||
<literal>java.io.tmpdir</literal> directory.</entry>
|
|
||||||
</row>
|
</row>
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</table></para>
|
</table></para>
|
||||||
</section>
|
</section>
|
||||||
</chapter>
|
</chapter>
|
||||||
|
|
||||||
<appendix>
|
<appendix>
|
||||||
<title>Further information</title>
|
<title>Further information</title>
|
||||||
|
|
||||||
<para>For further usage question or problems consult the <ulink
|
<para>For further usage question or problems consult the <ulink
|
||||||
url="https://forum.hibernate.org/viewforum.php?f=9">Hibernate
|
url="https://forum.hibernate.org/viewforum.php?f=9">Hibernate Forum</ulink>. For bug reports
|
||||||
Forum</ulink>. For bug reports use the <ulink
|
use the <ulink url="http://opensource.atlassian.com/projects/hibernate/browse/METAGEN"
|
||||||
url="http://opensource.atlassian.com/projects/hibernate/browse/METAGEN"
|
userlevel="">METAGEN</ulink> project in the Hibernate Jira instance. Feedback is always
|
||||||
userlevel="">METAGEN</ulink> project in the Hibernate Jira instance.
|
welcome.</para>
|
||||||
Feedback is always welcome.</para>
|
|
||||||
</appendix>
|
</appendix>
|
||||||
|
<bibliography>
|
||||||
|
<title>References</title>
|
||||||
|
<biblioentry id="JSR_269">
|
||||||
|
<abbrev id="JSR_269_ABBREV">Pluggable Annotation Processing API</abbrev>
|
||||||
|
<title>JSR 269: Pluggable Annotation Processing API</title>
|
||||||
|
<copyright>
|
||||||
|
<year>2006</year>
|
||||||
|
<holder>SUN MICROSYSTEMS, INC.</holder>
|
||||||
|
</copyright>
|
||||||
|
<bibliomisc>
|
||||||
|
<email>jsr-269-feedback@sun.com</email>
|
||||||
|
<ulink url="http://jcp.org/en/jsr/detail?id=269">JSR 269 JCP Page</ulink>
|
||||||
|
</bibliomisc>
|
||||||
|
</biblioentry>
|
||||||
|
<biblioentry id="JPA2">
|
||||||
|
<abbrev id="JPA2_ABBREV">JPA 2 Specification</abbrev>
|
||||||
|
<title>JSR 317: <trademark>Java</trademark> Persistence API, Version 2.0 </title>
|
||||||
|
<collab>
|
||||||
|
<collabname>Java Persistence 2.0 Expert Group</collabname>
|
||||||
|
</collab>
|
||||||
|
<copyright>
|
||||||
|
<year>2009</year>
|
||||||
|
<holder>SUN MICROSYSTEMS, INC.</holder>
|
||||||
|
</copyright>
|
||||||
|
<bibliomisc>
|
||||||
|
<email>jsr-317-feedback@sun.com</email>
|
||||||
|
<ulink url="http://jcp.org/en/jsr/detail?id=317">JSR 317 JCP Page</ulink>
|
||||||
|
</bibliomisc>
|
||||||
|
</biblioentry>
|
||||||
|
</bibliography>
|
||||||
</book>
|
</book>
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
|
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
|
||||||
version="1.0"
|
version="1.0"
|
||||||
>
|
>
|
||||||
|
<!-- use orm_1_0 on purpose (backward compatibility test -->
|
||||||
<package>org.hibernate.jpamodelgen.test.model</package>
|
<package>org.hibernate.jpamodelgen.test.model</package>
|
||||||
<entity class="Airplane" metadata-complete="true" access="PROPERTY">
|
<entity class="Airplane" metadata-complete="true" access="PROPERTY">
|
||||||
<attributes>
|
<attributes>
|
||||||
|
|
Loading…
Reference in New Issue