diff --git a/tooling/metamodel-generator/src/main/docbook/en-US/master.xml b/tooling/metamodel-generator/src/main/docbook/en-US/master.xml
index f86e4f5e47..a84cbf0259 100644
--- a/tooling/metamodel-generator/src/main/docbook/en-US/master.xml
+++ b/tooling/metamodel-generator/src/main/docbook/en-US/master.xml
@@ -22,43 +22,60 @@
-'>
-'>
+">
+">
]>
Hibernate JPA 2 Metamodel Generator
+
Reference Guide
+
&version;
+
&today;
+
&version;
+
©rightYear;
+
©rightHolder;
+
Hardy
+
Ferentschik
-
+
+
+
Introduction
+
What is it about?
- JPA 2 defines a new typesafe Criteria API which allows criteria
- queries to be constructed in a strongly-typed manner, using metamodel objects to provide
- type safety. For developers it is important that the task of the metamodel generation can be
- automated. Hibernate Static Metamodel Generator is an annotation processor based on the
- &jsr269Ref; with the task of creating JPA 2 static metamodel classes. The following example
- show two JPA 2 entities Order and Item,
- together with the metamodel class Order_ and a typesafe query.
+
+ JPA 2 defines a new typesafe Criteria API
+ which allows criteria queries to be constructed in a strongly-typed
+ manner, using metamodel objects to provide type safety. For developers
+ it is important that the task of the metamodel generation can be
+ automated. Hibernate Static Metamodel Generator is an annotation
+ processor based on the &jsr269Ref; with the task of creating JPA 2
+ static metamodel classes. The following example show two JPA 2 entities
+ Order and Item, together
+ with the metamodel class Order_ and a typesafe
+ query.
+
JPA 2 annotated entities Order and
- Item
-
+ Item
+
+
@Entity
public class Order {
@Id
@@ -77,24 +94,26 @@ public class Order {
}
@Entity
-public class Item {
+public class Item {
@Id
@GeneratedValue
- Integer id;
-
- int quantity;
-
+ Integer id;
+
+ int quantity;
+
@ManyToOne
Order order;
-
+
// standard setter/getter methods
...
}
+
- Metamodel class Order_
-
+ Metamodel class Order_
+
+
@StaticMetamodel(Order.class)
public class Order_ {
public static volatile SingularAttribute<Order, Integer> id;
@@ -104,9 +123,11 @@ public class Order_ {
}
+
Typesafe citeria query
-
+
+
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<Order> cq = cb.createQuery(Order.class);
SetJoin<Order, Item> itemNode = cq.from(Order.class).join(Order_.items);
@@ -114,110 +135,164 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
+
+
+ The Metamodel Generator also takes into consideration xml
+ configuration specified in orm.xml or mapping files specified in
+ persistence.xml. However, if all configuration is in XML you need to
+ add in at least on of the mapping file the following persistence unit
+ metadata:<persistence-unit-metadata>
+ <xml-mapping-metadata-complete/>
+</persistence-unit-metadata>
+
+
Canonical Metamodel
- The structure of the metamodel classes is described in the &jpa2Ref;, but for completeness the definition
- is repeated in the following paragraphs. Feel free to skip ahead to if you are not interested into the gory details.
- The annotation processor produces for every managed class in the persistence unit a
- metamodel class based on these rules:
+
+ The structure of the metamodel classes is described in the
+ &jpa2Ref;, but for completeness the definition is repeated in the
+ following paragraphs. Feel free to skip ahead to if you are not interested into the gory
+ details.
+
+ The annotation processor produces for every managed class in the
+ persistence unit a metamodel class based on these rules:
+
- For each managed class X in package p, a metamodel class
- X_ in package p is created.
+ For each managed class X in package
+ p, a metamodel class X_ in package p is
+ created.
+
- The name of the metamodel class is derived from the name of the managed class by
- appending "_" to the name of the managed class.
+ The name of the metamodel class is derived from the name of
+ the managed class by appending "_" to the name of the managed
+ class.
+
- The metamodel class X_ must be annotated with the
- javax.persistence.StaticMetamodel annotation.
+ The metamodel class X_ must be
+ annotated with the
+ javax.persistence.StaticMetamodel
+ annotation.
+
- If class X extends another class S,
- where S is the most derived managed class (i.e., entity or
- mapped superclass) extended by X, then class
- X_ must extend class S_, where
- S_ is the metamodel class created for
- S.
+ If class X extends another class
+ S, where S is the
+ most derived managed class (i.e., entity or mapped superclass)
+ extended by X, then class
+ X_ must extend class
+ S_, where S_ is the
+ metamodel class created for S.
+
- For every persistent non-collection-valued attribute y declared by class
- X, where the type of y is Y, the
- metamodel class must contain a declaration as follows:
-
- public static volatile SingularAttribute<X, Y> y;
+ For every persistent non-collection-valued attribute y
+ declared by class X, where the type of y is
+ Y, the metamodel class must contain a
+ declaration as follows:
+
+ public static volatile SingularAttribute<X, Y> y;
+
- For every persistent collection-valued attribute z declared by class
- X, where the element type of z is Z,
- the metamodel class must contain a declaration as follows:
+ For every persistent collection-valued attribute z declared
+ by class X, where the element type of z is
+ Z, the metamodel class must contain a
+ declaration as follows:
- if the collection type of z is java.util.Collection, then
+ if the collection type of z is java.util.Collection,
+ then
+
public static volatile CollectionAttribute<X, Z> z;
+
- if the collection type of z is java.util.Set, then
+ if the collection type of z is java.util.Set,
+ then
+
public static volatile SetAttribute<X, Z> z;
+
- if the collection type of z is java.util.List, then
+ if the collection type of z is java.util.List,
+ then
+
public static volatile ListAttribute<X, Z> z;
+
if the collection type of z is java.util.Map, then
- public static volatile MapAttribute<X, K, Z> z;
- where K is the type of the key of the map in class X
+ public static volatile MapAttribute<X, K, Z> z;
+ where K is the type of the key of the map in class X
Import statements must be included for the needed
- javax.persistence.metamodel types as appropriate and all classes
- X, Y, Z, and
- K.
+ javax.persistence.metamodel types as appropriate
+ and all classes X, Y,
+ Z, and K.
+
Usage
+
The jar file for the annotation processor can be found in the JBoss Maven repository using .
+ url="http://repository.jboss.com/">JBoss Maven repository using
+ .
+
- Maven dependency
- <dependency>
+ Maven dependency
+
+ <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>1.0.0</version>
</dependency>
- Alternatively, a full distribution package can be downloaded from SourceForge.
- 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 Java's
- Service Provider contract and the fact the the Hibernate Static Metamodel Generator
- jar files contains the file javax.annotation.processing.Processor in
- the META-INF/services directory. The fully qualified name of the
- processor itself is:
- org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor.
+
+ Alternatively, a full distribution package can be downloaded from
+ SourceForge.
+
+ 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 Java's
+ Service Provider contract and the fact the the Hibernate Static
+ Metamodel Generator jar files contains the file
+ javax.annotation.processing.Processor in the
+ META-INF/services directory. The fully qualified name
+ of the processor itself is:
+ org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor.
+
The use of a Java 6 compiler is a prerequisite.
+
Usage from the command line
+
Usage with Ant
- 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
- useful to control the annotation processing in more detail, for example if you
- exclusively want to run the processor without compiling any other source files. shows how Ant's Javac Task can be
- configured to just run annotation processing.
+
+ 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 useful to control
+ the annotation processing in more detail, for example if you
+ exclusively want to run the processor without compiling any other
+ source files. shows how Ant's
+ Javac
+ Task can be configured to just run annotation
+ processing.
+
Javac Task configuration
- <javac srcdir="${src.dir}"
+
+ <javac srcdir="${src.dir}"
destdir="${target.dir}"
failonerror="false"
fork="true"
@@ -225,23 +300,33 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
<compilerarg value="-proc:only"/>
</javac>
- The option -proc:only instructs the compiler to just run the
- annotation processing. You can also completely disable processing by specifying
- -proc:none.
+
+ The option -proc:only instructs the
+ compiler to just run the annotation processing. You can also
+ completely disable processing by specifying
+ -proc:none.
+
- Run 'javac -help' to see which other annotation processor
- relevant options can be specified.
+ Run 'javac -help' to see which other
+ annotation processor relevant options can be specified.
+
Usage with Maven
- 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:
-
- Maven compiler plugin configuration - direct execution
- <plugin>
+
+ 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:
+
+
+ Maven compiler plugin configuration - direct
+ execution
+
+ <plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
@@ -251,17 +336,23 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
</compilerArguments>
</configuration>
</plugin>
-
- The maven-compiler-plugin approach has the disadvantage that the maven compiler plugin
- does currently not allow to specify multiple compiler arguments (MCOMPILER-62) and that
- messages from the Messenger API are suppressed (MCOMPILER-66). A better
- approach is to disable annotation processing for the compiler plugin as seen in .
+
+
+ The maven-compiler-plugin approach has the disadvantage that the
+ maven compiler plugin does currently not allow to specify multiple
+ compiler arguments (MCOMPILER-62)
+ and that messages from the Messenger API are suppressed (MCOMPILER-66).
+ A better approach is to disable annotation processing for the compiler
+ plugin as seen in .
+
- Maven compiler plugin configuration - indirect execution
- <plugin>
+ Maven compiler plugin configuration - indirect
+ execution
+
+ <plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
@@ -270,16 +361,21 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
</configuration>
</plugin>
- Once disabled, the maven-annotation-plugin for annotation processing (you will need the following
- additional maven repositories: maven-annotation-plugin and jfrog) can be used. The
- configuration can be seen in .
+
+ Once disabled, the maven-annotation-plugin
+ for annotation processing (you will need the following additional
+ maven repositories: maven-annotation-plugin
+ and jfrog)
+ can be used. The configuration can be seen in .
+
Configuration with maven-annotation-plugin
- <plugin>
+
+ <plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
@@ -318,133 +414,198 @@ cq.where( cb.equal(itemNode.get(Item_.id), 5 ) ).distinct(true);
+
Usage within the IDE
- Of course you also want to have annotation processing available in your favorite IDE.
- The following paragraphs and screenshots show you how to enable the Hibernate Static
- Metamodel Generator within your IDE.
+
+ Of course you also want to have annotation processing available in
+ your favorite IDE. The following paragraphs and screenshots show you how
+ to enable the Hibernate Static Metamodel Generator within your
+ IDE.
+
Idea
- Intellij Idea contains from version 9.x onwards a specifc configuration section for
- annotation processing under the project settings window. The screenshots show you how to
- configure the Hibernate Static Metamodel Generator.
+
+ Intellij Idea contains from version 9.x onwards a specifc
+ configuration section for annotation processing under the project
+ settings window. The screenshots show you how to configure the
+ Hibernate Static Metamodel Generator.
+
+ fileref="idea-annotation-processor-config.png"
+ scalefit="" />
+
-
+
+
Eclipse
- In Eclipse, from the Galileo release onwards, exists an additional configuration
- section under Java Compiler. There you can configure all kinds of aspects of annotation
- processing. Just check the "Enable annotation processing" option, configure the directory
- for the generated sources and finally add the Hibernate Static Metamodel Generator and JPA
- 2 jar files to the factory path.
+
+ In Eclipse, from the Galileo release onwards, exists an
+ additional configuration section under Java Compiler. There you can
+ configure all kinds of aspects of annotation processing. Just check
+ the "Enable annotation processing" option, configure the directory for
+ the generated sources and finally add the Hibernate Static Metamodel
+ Generator and JPA 2 jar files to the factory path.
+
+ fileref="eclipse-annotation-processor-config.png"
+ scalefit="" />
+
-
+
+
NetBeans
- Netbeans support for annotation processors is at the time of this wrinting still in
- the making. Refer to NetBeans issues 111065, 111293 and 111294.
+
+ Netbeans support for annotation processors is at the time of
+ this wrinting still in the making. Refer to NetBeans issues 111065,
+ 111293
+ and 111294.
+
Processor specific options
- The Hibernate Static Metamodel Generator accepts a series of custom options which can be
- passed to the processor in the format -A[property]=[value]. The supported
- properties are:
- Annotation processor options (passed via -A[property]=[value])
+
+ The Hibernate Static Metamodel Generator accepts a series of
+ custom options which can be passed to the processor in the format
+ -A[property]=[value]. The supported properties
+ are:
+ Annotation processor options (passed via
+ -A[property]=[value])
+
Option name
- Option value and usage
+
+ Option value and
+ usage
+
debug
- if set to true additional trace information will be
- outputted by the processor
+
+ if set to true additional trace
+ information will be outputted by the processor
+
persistenceXml
- Per default the processor looks in /META-INF for
- persistence.xml. Specifying this option a persitence.xml file
- from a different location can be specified (has to be on the classpath)
+
+ Per default the processor looks in
+ /META-INF for persistence.xml. Specifying
+ this option a persitence.xml file from a
+ different location can be specified (has to be on the
+ classpath)
+
ormXml
- Allows to specify additional entity mapping files. The specified value for
- this option is a comma separated string of mapping file names. Even when this
- option is specified /META-INF/orm.xml is implicit.
+
+ Allows to specify additional entity mapping files. The
+ specified value for this option is a comma separated string of
+ mapping file names. Even when this option is specified
+ /META-INF/orm.xml is implicit.
+
lazyXmlParsing
- Possible values are true or false. If
- set to true the annotation processor tries to determine whether
- any of the xml files has changed between invocations and if unchanged skips the
- xml parsing. This feature is experimental and contains the risk of wron results in
- some cases of mixed mode configurations. To determine wether a file has been
- modified a temporary file
- Hibernate-Static-Metamodel-Generator.tmp is used. This file
- gets created in the java.io.tmpdir directory.
+
+ Possible values are true or
+ false. If set to true
+ the annotation processor tries to determine whether any of the
+ xml files has changed between invocations and if unchanged
+ skips the xml parsing. This feature is experimental and
+ contains the risk of wron results in some cases of mixed mode
+ configurations. To determine wether a file has been modified a
+ temporary file
+ Hibernate-Static-Metamodel-Generator.tmp
+ is used. This file gets created in the
+ java.io.tmpdir directory.
+
+
+
+ fullyAnnotationConfigured
+
+ if set to true the processor will
+ ignore orm.xml and
+ persistence.xml.
+
Further information
+
For further usage question or problems consult the Hibernate Forum. For bug reports
- use the METAGEN project in the Hibernate Jira instance. Feedback is always
- welcome.
+ url="https://forum.hibernate.org/viewforum.php?f=9">Hibernate
+ Forum. For bug reports use the METAGEN project in the Hibernate Jira instance.
+ Feedback is always welcome.
+
References
+
Pluggable Annotation Processing API
+
JSR 269: Pluggable Annotation Processing API
+
2006
+
SUN MICROSYSTEMS, INC.
-
- jsr-269-feedback@sun.com
- JSR 269 JCP Page
-
+
+ jsr-269-feedback@sun.com JSR 269 JCP
+ Page
+
JPA 2 Specification
- JSR 317: Java Persistence API, Version 2.0
+
+ JSR 317: Java Persistence API, Version
+ 2.0
+
Java Persistence 2.0 Expert Group
+
2009
+
SUN MICROSYSTEMS, INC.
-
- jsr-317-feedback@sun.com
- JSR 317 JCP Page
-
+
+ jsr-317-feedback@sun.com JSR 317 JCP
+ Page
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java
index 853d3ab79b..9c02bcb91a 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/JPAMetaModelEntityProcessor.java
@@ -61,7 +61,9 @@ import static javax.lang.model.SourceVersion.RELEASE_6;
* @author Hardy Ferentschik
* @author Emmanuel Bernard
*/
-@SupportedAnnotationTypes("*")
+@SupportedAnnotationTypes({
+ "javax.persistence.Entity", "javax.persistence.MappedSuperclass", "javax.persistence.Embeddable"
+})
@SupportedSourceVersion(RELEASE_6)
@SupportedOptions({
JPAMetaModelEntityProcessor.DEBUG_OPTION,
@@ -79,9 +81,7 @@ public class JPAMetaModelEntityProcessor extends AbstractProcessor {
private static final Boolean ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS = Boolean.FALSE;
- private boolean xmlProcessed = false;
private Context context;
- private boolean fullyAnnotationConfigured = false;
public void init(ProcessingEnvironment env) {
super.init( env );
@@ -91,24 +91,28 @@ public class JPAMetaModelEntityProcessor extends AbstractProcessor {
);
String tmp = env.getOptions().get( JPAMetaModelEntityProcessor.FULLY_ANNOTATION_CONFIGURED_OPTION );
- fullyAnnotationConfigured = Boolean.parseBoolean( tmp );
+ boolean fullyAnnotationConfigured = Boolean.parseBoolean( tmp );
+
+ if ( !fullyAnnotationConfigured ) {
+ XmlParser parser = new XmlParser( context );
+ parser.parseXml();
+ if ( context.isPersistenceUnitCompletelyXmlConfigured() ) {
+ createMetaModelClasses();
+ }
+ }
}
@Override
public boolean process(final Set extends TypeElement> annotations, final RoundEnvironment roundEnvironment) {
if ( roundEnvironment.processingOver() ) {
- context.logMessage( Diagnostic.Kind.OTHER, "Last processing round." );
- createMetaModelClasses();
- context.logMessage( Diagnostic.Kind.OTHER, "Finished processing" );
+ if ( !context.isPersistenceUnitCompletelyXmlConfigured() ) {
+ context.logMessage( Diagnostic.Kind.OTHER, "Last processing round." );
+ createMetaModelClasses();
+ context.logMessage( Diagnostic.Kind.OTHER, "Finished processing" );
+ }
return ALLOW_OTHER_PROCESSORS_TO_CLAIM_ANNOTATIONS;
}
- if ( !fullyAnnotationConfigured && !xmlProcessed ) {
- XmlParser parser = new XmlParser( context );
- parser.parseXml();
- xmlProcessed = true;
- }
-
if ( context.isPersistenceUnitCompletelyXmlConfigured() ) {
context.logMessage(
Diagnostic.Kind.OTHER,
diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/model/ImportContext.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/model/ImportContext.java
index e56e53f043..29b6783455 100644
--- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/model/ImportContext.java
+++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/model/ImportContext.java
@@ -38,10 +38,9 @@ public interface ImportContext {
*
* @return import string
*/
- public abstract String importType(String fqcn);
+ String importType(String fqcn);
- public abstract String staticImport(String fqcn, String member);
-
- public abstract String generateImports();
+ String staticImport(String fqcn, String member);
+ String generateImports();
}
\ No newline at end of file
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmetacomplete/Dummy.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmetacomplete/Dummy.java
new file mode 100644
index 0000000000..91c89274a5
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmetacomplete/Dummy.java
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// $Id:$
+package org.hibernate.jpamodelgen.test.xmlmetacomplete;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Entity
+public class Dummy {
+ @Id
+ private long id;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+}
+
+
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmetacomplete/XmlMetaDataCompleteTest.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmetacomplete/XmlMetaDataCompleteTest.java
new file mode 100644
index 0000000000..e9e3df220c
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlmetacomplete/XmlMetaDataCompleteTest.java
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// $Id: XmlMappingTest.java 20721 2010-09-27 12:40:10Z hardy.ferentschik $
+
+package org.hibernate.jpamodelgen.test.xmlmetacomplete;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.testng.annotations.Test;
+
+import org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor;
+import org.hibernate.jpamodelgen.test.util.CompilationTest;
+import org.hibernate.jpamodelgen.test.util.TestUtil;
+
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertNoSourceFileGeneratedFor;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class XmlMetaDataCompleteTest extends CompilationTest {
+ @Test
+ public void testNoMetaModelGenerated() {
+ // the xml mapping files used in the example say that the xml data is meta complete. For that
+ // reason there should be no meta model source file for the annotated Dummy entity
+ assertNoSourceFileGeneratedFor( Dummy.class );
+ }
+
+ @Override
+ protected String getPackageNameOfTestSources() {
+ return XmlMetaDataCompleteTest.class.getPackage().getName();
+ }
+
+ @Override
+ protected Map getProcessorOptions() {
+ Map properties = new HashMap();
+ properties.put(
+ JPAMetaModelEntityProcessor.PERSISTENCE_XML_OPTION,
+ TestUtil.fcnToPath( XmlMetaDataCompleteTest.class.getPackage().getName() ) + "/persistence.xml"
+ );
+ return properties;
+ }
+}
\ No newline at end of file
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlonly/XmlOnly.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlonly/XmlOnly.java
new file mode 100644
index 0000000000..8b4be2d923
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlonly/XmlOnly.java
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// $Id:$
+package org.hibernate.jpamodelgen.test.xmlonly;
+
+/**
+ * @author Hardy Ferentschik
+ */
+
+public class XmlOnly {
+ private long id;
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+}
+
+
diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlonly/XmlOnlyTest.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlonly/XmlOnlyTest.java
new file mode 100644
index 0000000000..719a802a1c
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/xmlonly/XmlOnlyTest.java
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// $Id$
+
+package org.hibernate.jpamodelgen.test.xmlonly;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.testng.annotations.Test;
+
+import org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor;
+import org.hibernate.jpamodelgen.test.util.CompilationTest;
+import org.hibernate.jpamodelgen.test.util.TestUtil;
+
+import static org.hibernate.jpamodelgen.test.util.TestUtil.assertMetamodelClassGeneratedFor;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class XmlOnlyTest extends CompilationTest {
+ @Test
+ public void testMetaModelGeneratedForXmlConiguredEntity() {
+ assertMetamodelClassGeneratedFor( XmlOnly.class );
+ }
+
+ @Override
+ protected String getPackageNameOfTestSources() {
+ return XmlOnlyTest.class.getPackage().getName();
+ }
+
+ @Override
+ protected Map getProcessorOptions() {
+ Map properties = new HashMap();
+ properties.put(
+ JPAMetaModelEntityProcessor.PERSISTENCE_XML_OPTION,
+ TestUtil.fcnToPath( XmlOnlyTest.class.getPackage().getName() ) + "/persistence.xml"
+ );
+ return properties;
+ }
+}
\ No newline at end of file
diff --git a/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmetacomplete/foo.xml b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmetacomplete/foo.xml
new file mode 100644
index 0000000000..359e80e7ac
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmetacomplete/foo.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
diff --git a/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmetacomplete/persistence.xml b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmetacomplete/persistence.xml
new file mode 100644
index 0000000000..990710a210
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlmetacomplete/persistence.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ /org/hibernate/jpamodelgen/test/xmlmetacomplete/foo.xml
+
+
diff --git a/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlonly/persistence.xml b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlonly/persistence.xml
new file mode 100644
index 0000000000..155f996f7f
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlonly/persistence.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ /org/hibernate/jpamodelgen/test/xmlonly/xmlonly.xml
+
+
diff --git a/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlonly/xmlonly.xml b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlonly/xmlonly.xml
new file mode 100644
index 0000000000..6f94048b5a
--- /dev/null
+++ b/tooling/metamodel-generator/src/test/resources/org/hibernate/jpamodelgen/test/xmlonly/xmlonly.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+ org.hibernate.jpamodelgen.test.xmlonly
+
+
+
+
+
+