METAGEN-26 Updated readme and docbook sources
This commit is contained in:
parent
67a89cb2d7
commit
f80bf48a5b
|
@ -4,9 +4,9 @@
|
|||
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>1.1.0-SNAPSHOT</version>
|
||||
|
||||
<name>JPA 2 Static-Metamodel Generator</name>
|
||||
<name>Hibernate JPA 2 Metamodel Generator</name>
|
||||
<description>Annotation Processor to generate JPA 2 static metamodel classes</description>
|
||||
|
||||
<inceptionYear>2009</inceptionYear>
|
||||
|
@ -15,7 +15,7 @@
|
|||
<dependency>
|
||||
<groupId>org.hibernate.javax.persistence</groupId>
|
||||
<artifactId>hibernate-jpa-2.0-api</artifactId>
|
||||
<version>1.0.0-CR-1</version>
|
||||
<version>1.0.0.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
|
@ -202,12 +202,12 @@
|
|||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Implementation-Title>${pom.artifactId}</Implementation-Title>
|
||||
<Created-By>${java.version} (${java.vendor})</Created-By>
|
||||
<Implementation-Title>${pom.name}</Implementation-Title>
|
||||
<Implementation-URL>http://www.jboss.org/</Implementation-URL>
|
||||
<Implementation-Version>${pom.version}</Implementation-Version>
|
||||
<Implementation-Vendor>${pom.groupId}</Implementation-Vendor>
|
||||
<Implementation-Vendor-Id>${pom.groupId}</Implementation-Vendor-Id>
|
||||
<Implementation-URL>${pom.url}</Implementation-URL>
|
||||
<Specification-Title>JPA2 Model Generator</Specification-Title>
|
||||
<Implementation-Vendor>JBoss by Red Hat, Inc.</Implementation-Vendor>
|
||||
<Implementation-Vendor-Id>http://www.jboss.org/</Implementation-Vendor-Id>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
JPA Model Generator
|
||||
Hibernate JPA 2 Metamodel Generator
|
||||
|
||||
What is it?
|
||||
-----------
|
||||
|
||||
This is a Java 6 annotation processor generating meta model classes for the JPA 2 criteria queries.
|
||||
The processor (JPAMetaModelEntityProcessor) processes all classes annotated with @Entity, as well as
|
||||
entities mapped in /META-INF/orm.xml and mapping files specified in persistence.xml.
|
||||
|
||||
|
||||
Status
|
||||
------
|
||||
|
||||
This is an alpha release of the annotation processor. The implemented functionality includes:
|
||||
- full support for annotations honoring the access type (v2.0)
|
||||
- support for persistence.xml, orm.xml and <mapping-file>
|
||||
- tests (both via compilation failure and regular assertion failure)
|
||||
The processor (JPAMetaModelEntityProcessor) processes all classes annotated with @Entity, @MappedSuperclass
|
||||
or @Embeddable, as well as entities mapped in /META-INF/orm.xml and mapping files specified in persistence.xml.
|
||||
|
||||
|
||||
System Requirements
|
||||
|
@ -23,41 +14,30 @@
|
|||
JDK 1.6 or above.
|
||||
|
||||
|
||||
Issues
|
||||
------
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
See issues.txt
|
||||
http://docs.jboss.org/hibernate/stable/jpamodelgen/reference/en-US/
|
||||
|
||||
|
||||
Using JPA Model Generator
|
||||
-------------------------
|
||||
Licensing
|
||||
---------
|
||||
|
||||
Please see the file called license.txt
|
||||
|
||||
|
||||
Resources
|
||||
---------
|
||||
|
||||
Home Page: http://www.hibernate.org/
|
||||
Mailing Lists: http://www.hibernate.org/20.html
|
||||
Source Code: http://anonsvn.jboss.org/repos/hibernate/jpamodelgen/trunk/
|
||||
Issue Tracking: http://opensource.atlassian.com/projects/hibernate/browse/METAGEN
|
||||
|
||||
|
||||
- Copy jpamodelgen-*.jar together will all jar files from lib into the classpath of your application.
|
||||
The jpamodelgen jar file contains a service file (/META-INF/services/javax.annotation.processing.Processor)
|
||||
so that the annotation processor will automatically be executed during compilation.
|
||||
You can also explicitly specify the processor using the -processor flag:
|
||||
> javac -cp <myclasspath> -d <target> -sourcepath <sources> -processor org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
|
||||
|
||||
|
||||
* Maven
|
||||
This distribution contains a pom.xml file showing one of three possible ways to integrate the processor in a maven project.
|
||||
You can just add <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor> to the maven-compiler-plugin.
|
||||
This approach has, however, the shortcoming that messages from the annotation processor are not displayed. This is a known
|
||||
issue. See also - http://weblogs.java.net/blog/ss141213/archive/2007/11/my_maven_experi.html
|
||||
The second alternative is the maven-annotation-plugin (http://code.google.com/p/maven-annotation-plugin/). This approach
|
||||
hasn't been tested yet.
|
||||
Last but not least, you can use the maven-antrun-plugin to just run the annotation processor and ignore the processor in
|
||||
in the maven-compiler-plugin via '-proc:none'. This is the approach chosen in the POM for this project.
|
||||
|
||||
* Ant
|
||||
Make sure the annotation processor and its dependencies are in the classpath. Due the service file the processor will be
|
||||
automatically executed when the javac task executes.
|
||||
If not try adding <compilerarg value="-processor org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor"/>
|
||||
|
||||
* Idea
|
||||
Again, if in the classpath the JPAMetaModelEntityProcessor should execute automatically. If not add the following under
|
||||
'Compiler->Java Compiler': -target 1.6 -processor org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
|
||||
You can also turn of annotation processing via: -target 1.6 -proc:none
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
||||
<!ENTITY version "WORKING">
|
||||
<!ENTITY today "TODAY">
|
||||
<!ENTITY copyrightYear "2010">
|
||||
<!ENTITY copyrightHolder "Red Hat Inc.">
|
||||
<!ENTITY jpa2Ref '<citation><xref linkend="JPA2"/></citation>'>
|
||||
|
@ -26,20 +27,26 @@
|
|||
]>
|
||||
<book lang="en">
|
||||
<bookinfo>
|
||||
<title>Hibernate Metamodel Generator</title>
|
||||
<subtitle>JPA 2 Static Metamodel Annotation Processor</subtitle>
|
||||
<title>Hibernate JPA 2 Metamodel Generator</title>
|
||||
<subtitle>Reference Guide</subtitle>
|
||||
<releaseinfo>&version;</releaseinfo>
|
||||
<pubdate>&today;</pubdate>
|
||||
<productnumber>&version;</productnumber>
|
||||
<copyright>
|
||||
<year>©rightYear;</year>
|
||||
<holder>©rightHolder;</holder>
|
||||
</copyright>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<firstname>Hardy</firstname>
|
||||
<surname>Ferentschik</surname>
|
||||
</author>
|
||||
</authorgroup>
|
||||
</bookinfo>
|
||||
<toc/>
|
||||
<chapter id="introduction">
|
||||
<title>Introduction</title>
|
||||
<section id="whatisit" revision="1">
|
||||
<section id="whatisit">
|
||||
<title>What is it about?</title>
|
||||
<para>JPA 2 defines a new typesafe <classname>Criteria</classname> API which allows criteria
|
||||
queries to be constructed in a strongly-typed manner, using metamodel objects to provide
|
||||
|
@ -51,7 +58,7 @@
|
|||
<example id="jpa2-entity-example">
|
||||
<title>JPA 2 annotated entities <classname>Order</classname> and
|
||||
<classname>Item</classname></title>
|
||||
<programlisting>
|
||||
<programlisting role="JAVA" language="JAVA">
|
||||
@Entity
|
||||
public class Order {
|
||||
@Id
|
||||
|
@ -87,7 +94,7 @@ public class Item {
|
|||
</example>
|
||||
<example id="metamodel-class-example">
|
||||
<title>Metamodel class <classname>Order_</classname></title>
|
||||
<programlisting>
|
||||
<programlisting role="JAVA" language="JAVA">
|
||||
@StaticMetamodel(Order.class)
|
||||
public class Order_ {
|
||||
public static volatile SingularAttribute<Order, Integer> id;
|
||||
|
@ -99,11 +106,12 @@ public class Order_ {
|
|||
</example>
|
||||
<example id="criteria-example">
|
||||
<title>Typesafe citeria query</title>
|
||||
<programlisting>
|
||||
<programlisting role="JAVA" language="JAVA">
|
||||
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
|
||||
CriteriaQuery<Order> cq = cb.createQuery(Order.class);
|
||||
SetJoin<Order, Item> itemNode = cq.from(Order.class).join(Order_.items);
|
||||
cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
</section>
|
||||
|
@ -139,23 +147,24 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
|||
<para>For every persistent non-collection-valued attribute y declared by class
|
||||
<classname>X</classname>, where the type of y is <classname>Y</classname>, the
|
||||
metamodel class must contain a declaration as follows:
|
||||
<programlisting>public static volatile SingularAttribute<X, Y> y;</programlisting></para>
|
||||
</para>
|
||||
<programlisting>public static volatile SingularAttribute<X, Y> y;</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>For every persistent collection-valued attribute z declared by class
|
||||
<classname>X</classname>, where the element type of z is <classname>Z</classname>,
|
||||
the metamodel class must contain a declaration as follows:<itemizedlist>
|
||||
<listitem>
|
||||
<para>if the collection type of z is java.util.Collection, then
|
||||
<programlisting>public static volatile CollectionAttribute<X, Z> z;</programlisting></para>
|
||||
<para>if the collection type of z is java.util.Collection, then</para>
|
||||
<programlisting>public static volatile CollectionAttribute<X, Z> z;</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>if the collection type of z is java.util.Set, then
|
||||
<programlisting>public static volatile SetAttribute<X, Z> z;</programlisting></para>
|
||||
<para>if the collection type of z is java.util.Set, then</para>
|
||||
<programlisting>public static volatile SetAttribute<X, Z> z;</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>if the collection type of z is java.util.List, then
|
||||
<programlisting>public static volatile ListAttribute<X, Z> z;</programlisting></para>
|
||||
<para>if the collection type of z is java.util.List, then</para>
|
||||
<programlisting>public static volatile ListAttribute<X, Z> z;</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>if the collection type of z is java.util.Map, then
|
||||
|
@ -177,14 +186,14 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
|||
linkend="maven-dependency"/>.</para>
|
||||
<example id="maven-dependency">
|
||||
<title>Maven dependency </title>
|
||||
<programlisting><dependency>
|
||||
<programlisting role="XML" language="XML"><dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-jpamodelgen</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency></programlisting>
|
||||
</example>
|
||||
<para>Alternatively, a full distribution package can be downloaded from <ulink
|
||||
url="http://sourceforge.net/projects/hibernate">SourceForge</ulink>.</para>
|
||||
url="http://sourceforge.net/projects/hibernate/files/hibernate-jpamodelgen">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
|
||||
url="http://java.sun.com/j2se/1.4.2/docs/guide/jar/jar.html#Service%20Provider">Java's
|
||||
|
@ -197,7 +206,7 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
|||
</note></para>
|
||||
<section>
|
||||
<title>Usage from the command line</title>
|
||||
<section id="usage-ant" revision="1">
|
||||
<section id="usage-ant">
|
||||
<title>Usage with Ant</title>
|
||||
<para>As mentioned before, the annotation processor will run automatically each time the
|
||||
Java compiler is called, provided the jar file is on the classpath. Sometimes, however, it is
|
||||
|
@ -208,12 +217,12 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
|||
configured to just run annotation processing.</para>
|
||||
<example id="javac-task-example">
|
||||
<title>Javac Task configuration</title>
|
||||
<programlisting><javac srcdir="${src.dir}"
|
||||
<programlisting role="XML" language="XML"><javac srcdir="${src.dir}"
|
||||
destdir="${target.dir}"
|
||||
failonerror="false"
|
||||
fork="true"
|
||||
classpath="${classpath}">
|
||||
<emphasis role="bold"><compilerarg value="-proc:only"/></emphasis>
|
||||
<compilerarg value="-proc:only"/>
|
||||
</javac></programlisting>
|
||||
</example>
|
||||
<para>The option <emphasis>-proc:only</emphasis> instructs the compiler to just run the
|
||||
|
@ -224,27 +233,25 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
|||
relevant options can be specified.</para>
|
||||
</tip>
|
||||
</section>
|
||||
<section revision="1">
|
||||
<section>
|
||||
<title>Usage with Maven</title>
|
||||
<para>There are several ways of running the annotation processor as part of a Maven build.
|
||||
Again, it will automatically run if you are using a JDK 6 compiler and the annotation
|
||||
processor jar is on the classpath. In case you have more than one annotation processors on
|
||||
your classpath you can explicitly pass the processor option to the compiler plugin:</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Maven compiler plugin configuration - direct execution</title>
|
||||
<programlisting><plugin>
|
||||
<programlisting role="XML" language="XML"><plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<compilerArguments>
|
||||
<emphasis role="bold"><processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor></emphasis>
|
||||
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</plugin></programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>The maven-compiler-plugin approach has the disadvantage that the maven compiler plugin
|
||||
does currently not allow to specify multiple compiler arguments (<ulink
|
||||
url="http://jira.codehaus.org/browse/MCOMPILER-62">MCOMPILER-62</ulink>) and that
|
||||
|
@ -254,12 +261,12 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
|||
linkend="disable-processing-maven-compiler-plugin"/>.</para>
|
||||
<example id="disable-processing-maven-compiler-plugin">
|
||||
<title>Maven compiler plugin configuration - indirect execution</title>
|
||||
<programlisting><plugin>
|
||||
<programlisting role="XML" language="XML"><plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<emphasis role="bold"><compilerArgument>-proc:none</compilerArgument></emphasis>
|
||||
<compilerArgument>-proc:none</compilerArgument>
|
||||
</configuration>
|
||||
</plugin></programlisting>
|
||||
</example>
|
||||
|
@ -271,8 +278,8 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
|
|||
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">
|
||||
<title>Maven compiler plugin configuration with maven-annotation-plugin</title>
|
||||
<programlisting><plugin>
|
||||
<title>Configuration with maven-annotation-plugin</title>
|
||||
<programlisting role="XML" language="XML"><plugin>
|
||||
<groupId>org.bsc.maven</groupId>
|
||||
<artifactId>maven-processor-plugin</artifactId>
|
||||
<executions>
|
||||
|
|
Loading…
Reference in New Issue