Author: hardy.ferentschik
Date: 2009-07-10 12:23:22 -0400 (Fri, 10 Jul 2009)
New Revision: 17070
Added:
jpamodelgen/trunk/generator/src/main/xsd/persistence_2_0.xsd
jpamodelgen/trunk/generator/src/test/resources/META-INF/jpa1-orm.xml
jpamodelgen/trunk/generator/src/test/resources/META-INF/malformed-mapping-xml.xml
Removed:
jpamodelgen/trunk/generator/src/main/xsd/persistence.xsd
Modified:
jpamodelgen/trunk/generator/pom.xml
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
jpamodelgen/trunk/generator/src/test/resources/META-INF/order.xml
jpamodelgen/trunk/generator/src/test/resources/META-INF/persistence.xml
Log:
xml parsing validates now against the xsd
Modified: jpamodelgen/trunk/generator/pom.xml
===================================================================
--- jpamodelgen/trunk/generator/pom.xml 2009-07-10 16:02:57 UTC (rev 17069)
+++ jpamodelgen/trunk/generator/pom.xml 2009-07-10 16:23:22 UTC (rev 17070)
@@ -27,8 +27,10 @@
<resources>
<resource>
<directory>src/main/resources</directory>
- <filtering>true</filtering>
</resource>
+ <resource>
+ <directory>src/main/xsd</directory>
+ </resource>
</resources>
<plugins>
<plugin>
Modified:
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java
===================================================================
---
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-07-10
16:02:57 UTC (rev 17069)
+++
jpamodelgen/trunk/generator/src/main/java/org/hibernate/jpa/metamodel/ap/JPAMetaModelEntityProcessor.java 2009-07-10
16:23:22 UTC (rev 17070)
@@ -3,6 +3,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.net.URL;
import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -26,7 +27,11 @@
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import org.xml.sax.SAXException;
+
import org.hibernate.jpa.metamodel.ap.annotation.MetaEntity;
import org.hibernate.jpa.metamodel.ap.xml.XmlMetaEntity;
import org.hibernate.jpa.metamodel.xml.jaxb.Entity;
@@ -54,6 +59,8 @@
private static final String MAPPED_SUPERCLASS_ANN = MappedSuperclass.class.getName();
private static final String EMBEDDABLE_ANN = Embeddable.class.getName();
private static final AccessType DEFAULT_XML_ACCESS_TYPE = AccessType.PROPERTY;
+ private static final String PERSISTENCE_XML_XSD = "persistence_2_0.xsd";
+ private static final String ORM_XSD = "orm_2_0.xsd";
private boolean xmlProcessed = false;
private Context context;
@@ -134,7 +141,7 @@
}
private void parsePersistenceXml() {
- Persistence persistence = parseXml( PERSISTENCE_XML, Persistence.class );
+ Persistence persistence = parseXml( PERSISTENCE_XML, Persistence.class,
PERSISTENCE_XML_XSD );
if ( persistence != null )
{
@@ -149,9 +156,8 @@
xmlProcessed = true;
}
-
private void parsingOrmXml(String resource) {
- EntityMappings mappings = parseXml( resource, EntityMappings.class );
+ EntityMappings mappings = parseXml( resource, EntityMappings.class, ORM_XSD );
if ( mappings == null ) {
return;
}
@@ -319,7 +325,7 @@
String pkg = getPackage( resource );
String name = getRelativeName( resource );
processingEnv.getMessager()
- .printMessage( Diagnostic.Kind.NOTE, "Checking for " + resource );
+ .printMessage( Diagnostic.Kind.NOTE, "Reading resource " + resource );
InputStream ormStream;
try {
FileObject fileObject = processingEnv.getFiler().getResource(
StandardLocation.CLASS_OUTPUT, pkg, name );
@@ -347,10 +353,11 @@
*
* @param resource the xml file name
* @param clazz The type of jaxb node to return
+ * @param schemaName The schema to validate against (can be {@code null});
*
* @return The top level jaxb instance contained in the xml file or {@code null} in case
the file could not be found.
*/
- private <T> T parseXml(String resource, Class<T> clazz) {
+ private <T> T parseXml(String resource, Class<T> clazz, String schemaName)
{
InputStream stream = getInputStreamForResource( resource );
@@ -361,19 +368,19 @@
try {
JAXBContext jc = JAXBContext.newInstance( ObjectFactory.class );
Unmarshaller unmarshaller = jc.createUnmarshaller();
+ if ( schemaName != null ) {
+ unmarshaller.setSchema( getSchema( schemaName ) );
+ }
return clazz.cast( unmarshaller.unmarshal( stream ) );
}
catch ( JAXBException e ) {
- processingEnv.getMessager().printMessage( Diagnostic.Kind.NOTE, "Error
unmarshalling " + resource );
- e.printStackTrace();
+ String message = "Error unmarshalling " + resource + " with exception
:\n " + e;
+ processingEnv.getMessager().printMessage( Diagnostic.Kind.WARNING, message );
return null;
}
catch ( Exception e ) {
- processingEnv.getMessager().printMessage(
- Diagnostic.Kind.ERROR,
- "Problem while reading " + resource + " " + e.getMessage()
- );
- e.printStackTrace();
+ String message = "Error reading " + resource + " with exception :\n
" + e;
+ processingEnv.getMessager().printMessage( Diagnostic.Kind.WARNING, message );
return null;
}
}
@@ -395,4 +402,23 @@
return resourceName.substring( resourceName.lastIndexOf( PATH_SEPARATOR ) + 1 );
}
}
+
+ private Schema getSchema(String schemaName) {
+ Schema schema = null;
+ URL schemaUrl = this.getClass().getClassLoader().getResource( schemaName );
+ if ( schemaUrl == null ) {
+ return schema;
+ }
+
+ SchemaFactory sf = SchemaFactory.newInstance(
javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI );
+ try {
+ schema = sf.newSchema( schemaUrl );
+ }
+ catch ( SAXException e ) {
+ processingEnv.getMessager().printMessage(
+ Diagnostic.Kind.WARNING, "Unable to create schema for " + schemaName +
": " + e.getMessage()
+ );
+ }
+ return schema;
+ }
}
Deleted: jpamodelgen/trunk/generator/src/main/xsd/persistence.xsd
===================================================================
--- jpamodelgen/trunk/generator/src/main/xsd/persistence.xsd 2009-07-10 16:02:57 UTC (rev
17069)
+++ jpamodelgen/trunk/generator/src/main/xsd/persistence.xsd 2009-07-10 16:23:22 UTC (rev
17070)
@@ -1,247 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- persistence.xml schema -->
-<xsd:schema
targetNamespace="http://java.sun.com/xml/ns/persistence"
-
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
-
xmlns:persistence="http://java.sun.com/xml/ns/persistence"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified"
- version="2.0">
- <xsd:annotation>
- <xsd:documentation>
- @(#)persistence_2_0.xsd 1.0 August 27 2008
- </xsd:documentation>
- </xsd:annotation>
- <xsd:annotation>
- <xsd:documentation><![CDATA[
-This is the XML Schema for the persistence configuration file.
-The file must be named "META-INF/persistence.xml" in the
-persistence archive.
-Persistence configuration files must indicate
-the persistence schema by using the persistence namespace:
-http://java.sun.com/xml/ns/persistence
-and indicate the version of the schema by
-using the version element as shown below:
-<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
-xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
-http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
-version="2.0">
-...
-</persistence>
-]]></xsd:documentation>
- </xsd:annotation>
- <xsd:simpleType name="versionType">
- <xsd:restriction base="xsd:token">
- <xsd:pattern value="[0-9]+(\.[0-9]+)*"/>
- </xsd:restriction>
- </xsd:simpleType>
- <!-- **************************************************** -->
- <xsd:element name="persistence">
- <xsd:complexType>
- <xsd:sequence>
- <!-- **************************************************** -->
- <xsd:element name="persistence-unit"
- minOccurs="1" maxOccurs="unbounded">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>Configuration of a persistence
unit.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <!-- ****************************************************
-->
- <xsd:element name="description"
type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Description of this persistence unit.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <!-- ****************************************************
-->
- <xsd:element name="provider"
type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Provider class that supplies EntityManagers for
this
- persistence unit.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <!-- ****************************************************
-->
- <xsd:element name="jta-data-source"
type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The container-specific name of the JTA datasource
to use.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <!-- ****************************************************
-->
- <xsd:element name="non-jta-data-source"
type="xsd:string"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- The container-specific name of a non-JTA
datasource to use.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <!-- ****************************************************
-->
- <xsd:element name="mapping-file"
type="xsd:string"
- minOccurs="0"
maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>File containing mapping
information. Loaded as a resource
- by the persistence provider.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <!-- ****************************************************
-->
- <xsd:element name="jar-file"
type="xsd:string"
- minOccurs="0"
maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- Jar file that should be scanned for entities.
- Not applicable to Java SE persistence units.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <!-- ****************************************************
-->
- <xsd:element name="class"
type="xsd:string"
- minOccurs="0"
maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- Class to scan for annotations. It should be
annotated
- with either @Entity, @Embeddable or
@MappedSuperclass.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <!-- ****************************************************
-->
- <xsd:element name="exclude-unlisted-classes"
type="xsd:boolean"
- default="false" minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- When set to true then only listed classes and
jars will
- be scanned for persistent classes, otherwise the
enclosing
- jar or directory will also be scanned. Not
applicable to
- Java SE persistence units.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <!-- ****************************************************
-->
- <xsd:element name="caching"
-
type="persistence:persistence-unit-caching-type"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Defines whether caching is enabled for the
- persistence unit if caching is supported by the
- persistence provider. When set to ALL, all
entities
- will be cached. When set to NONE, no entities
will
- be cached. When set to ENABLE_SELECTIVE, only
entities
- specified as cacheable will be cached. When set
toDISABLE_SELECTIVE, entities specified as not cacheable
- will not be cached.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <!-- ****************************************************
-->
- <xsd:element
- name="validation-mode"
-
type="persistence:persistence-unit-validation-mode-type"
- minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- Specifies the validation mode to be used for the
- persistence unit.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- <!-- ****************************************************
-->
- <xsd:element name="properties"
minOccurs="0">
- <xsd:annotation>
- <xsd:documentation>
- A list of vendor-specific properties.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="property"
- minOccurs="0"
maxOccurs="unbounded">
- <xsd:annotation>
- <xsd:documentation>
- A name-value pair.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexType>
- <xsd:attribute name="name"
type="xsd:string"
- use="required"/>
- <xsd:attribute name="value"
type="xsd:string"
- use="required"/>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- <!-- ****************************************************
-->
- <xsd:attribute name="name"
type="xsd:string" use="required">
- <xsd:annotation>
- <xsd:documentation>
- Name used in code to reference this persistence
unit.
- </xsd:documentation>
- </xsd:annotation></xsd:attribute>
- <!-- ****************************************************
-->
- <xsd:attribute name="transaction-type"
-
type="persistence:persistence-unit-transaction-type">
- <xsd:annotation>
- <xsd:documentation>
- Type of transactions used by EntityManagers from
this
- persistence unit.
- </xsd:documentation>
- </xsd:annotation>
- </xsd:attribute>
- </xsd:complexType>
- </xsd:element>
- </xsd:sequence>
- <xsd:attribute name="version"
type="persistence:versionType"
- fixed="2.0" use="required"/>
- </xsd:complexType>
- </xsd:element>
- <!-- **************************************************** -->
- <xsd:simpleType name="persistence-unit-transaction-type">
- <xsd:annotation>
- <xsd:documentation>
- public enum TransactionType { JTA, RESOURCE_LOCAL };
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="JTA"/>
- <xsd:enumeration value="RESOURCE_LOCAL"/>
- </xsd:restriction>
- </xsd:simpleType>
- <!-- **************************************************** -->
- <xsd:simpleType name="persistence-unit-caching-type">
- <xsd:annotation>
- <xsd:documentation>
- public enum CachingType { ALL, NONE, ENABLE_SELECTIVE,
- DISABLE_SELECTIVE};
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="ALL"/>
- <xsd:enumeration value="NONE"/>
- <xsd:enumeration value="ENABLE_SELECTIVE"/>
- <xsd:enumeration value="DISABLE_SELECTIVE"/>
- </xsd:restriction>
- </xsd:simpleType>
- <!-- **************************************************** -->
- <xsd:simpleType name="persistence-unit-validation-mode-type">
- <xsd:annotation>
- <xsd:documentation>public enum ValidationMode { AUTO, CALLBACK, NONE};
- </xsd:documentation>
- </xsd:annotation>
- <xsd:restriction base="xsd:token">
- <xsd:enumeration value="AUTO"/>
- <xsd:enumeration value="CALLBACK"/>
- <xsd:enumeration value="NONE"/>
- </xsd:restriction>
- </xsd:simpleType>
-</xsd:schema>
\ No newline at end of file
Copied: jpamodelgen/trunk/generator/src/main/xsd/persistence_2_0.xsd (from rev 17064,
jpamodelgen/trunk/generator/src/main/xsd/persistence.xsd)
===================================================================
--- jpamodelgen/trunk/generator/src/main/xsd/persistence_2_0.xsd
(rev 0)
+++ jpamodelgen/trunk/generator/src/main/xsd/persistence_2_0.xsd 2009-07-10 16:23:22 UTC
(rev 17070)
@@ -0,0 +1,247 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- persistence.xml schema -->
+<xsd:schema
targetNamespace="http://java.sun.com/xml/ns/persistence"
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
xmlns:persistence="http://java.sun.com/xml/ns/persistence"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="2.0">
+ <xsd:annotation>
+ <xsd:documentation>
+ @(#)persistence_2_0.xsd 1.0 August 27 2008
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:annotation>
+ <xsd:documentation><![CDATA[
+This is the XML Schema for the persistence configuration file.
+The file must be named "META-INF/persistence.xml" in the
+persistence archive.
+Persistence configuration files must indicate
+the persistence schema by using the persistence namespace:
+http://java.sun.com/xml/ns/persistence
+and indicate the version of the schema by
+using the version element as shown below:
+<persistence
xmlns="http://java.sun.com/xml/ns/persistence"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+version="2.0">
+...
+</persistence>
+]]></xsd:documentation>
+ </xsd:annotation>
+ <xsd:simpleType name="versionType">
+ <xsd:restriction base="xsd:token">
+ <xsd:pattern value="[0-9]+(\.[0-9]+)*"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:element name="persistence">
+ <xsd:complexType>
+ <xsd:sequence>
+ <!-- **************************************************** -->
+ <xsd:element name="persistence-unit"
+ minOccurs="1" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:annotation>
+ <xsd:documentation>Configuration of a persistence
unit.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:sequence>
+ <!-- ****************************************************
-->
+ <xsd:element name="description"
type="xsd:string"
+ minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ Description of this persistence unit.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- ****************************************************
-->
+ <xsd:element name="provider"
type="xsd:string"
+ minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ Provider class that supplies EntityManagers for
this
+ persistence unit.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- ****************************************************
-->
+ <xsd:element name="jta-data-source"
type="xsd:string"
+ minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The container-specific name of the JTA datasource
to use.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- ****************************************************
-->
+ <xsd:element name="non-jta-data-source"
type="xsd:string"
+ minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ The container-specific name of a non-JTA
datasource to use.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- ****************************************************
-->
+ <xsd:element name="mapping-file"
type="xsd:string"
+ minOccurs="0"
maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>File containing mapping
information. Loaded as a resource
+ by the persistence provider.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- ****************************************************
-->
+ <xsd:element name="jar-file"
type="xsd:string"
+ minOccurs="0"
maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>
+ Jar file that should be scanned for entities.
+ Not applicable to Java SE persistence units.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- ****************************************************
-->
+ <xsd:element name="class"
type="xsd:string"
+ minOccurs="0"
maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>
+ Class to scan for annotations. It should be
annotated
+ with either @Entity, @Embeddable or
@MappedSuperclass.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- ****************************************************
-->
+ <xsd:element name="exclude-unlisted-classes"
type="xsd:boolean"
+ default="false" minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ When set to true then only listed classes and
jars will
+ be scanned for persistent classes, otherwise the
enclosing
+ jar or directory will also be scanned. Not
applicable to
+ Java SE persistence units.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- ****************************************************
-->
+ <xsd:element name="caching"
+
type="persistence:persistence-unit-caching-type"
+ minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ Defines whether caching is enabled for the
+ persistence unit if caching is supported by the
+ persistence provider. When set to ALL, all
entities
+ will be cached. When set to NONE, no entities
will
+ be cached. When set to ENABLE_SELECTIVE, only
entities
+ specified as cacheable will be cached. When set
toDISABLE_SELECTIVE, entities specified as not cacheable
+ will not be cached.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- ****************************************************
-->
+ <xsd:element
+ name="validation-mode"
+
type="persistence:persistence-unit-validation-mode-type"
+ minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ Specifies the validation mode to be used for the
+ persistence unit.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:element>
+ <!-- ****************************************************
-->
+ <xsd:element name="properties"
minOccurs="0">
+ <xsd:annotation>
+ <xsd:documentation>
+ A list of vendor-specific properties.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="property"
+ minOccurs="0"
maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:documentation>
+ A name-value pair.
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:attribute name="name"
type="xsd:string"
+ use="required"/>
+ <xsd:attribute name="value"
type="xsd:string"
+ use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <!-- ****************************************************
-->
+ <xsd:attribute name="name"
type="xsd:string" use="required">
+ <xsd:annotation>
+ <xsd:documentation>
+ Name used in code to reference this persistence
unit.
+ </xsd:documentation>
+ </xsd:annotation></xsd:attribute>
+ <!-- ****************************************************
-->
+ <xsd:attribute name="transaction-type"
+
type="persistence:persistence-unit-transaction-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ Type of transactions used by EntityManagers from
this
+ persistence unit.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="version"
type="persistence:versionType"
+ fixed="2.0" use="required"/>
+ </xsd:complexType>
+ </xsd:element>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="persistence-unit-transaction-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ public enum TransactionType { JTA, RESOURCE_LOCAL };
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="JTA"/>
+ <xsd:enumeration value="RESOURCE_LOCAL"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="persistence-unit-caching-type">
+ <xsd:annotation>
+ <xsd:documentation>
+ public enum CachingType { ALL, NONE, ENABLE_SELECTIVE,
+ DISABLE_SELECTIVE};
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="ALL"/>
+ <xsd:enumeration value="NONE"/>
+ <xsd:enumeration value="ENABLE_SELECTIVE"/>
+ <xsd:enumeration value="DISABLE_SELECTIVE"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ <!-- **************************************************** -->
+ <xsd:simpleType name="persistence-unit-validation-mode-type">
+ <xsd:annotation>
+ <xsd:documentation>public enum ValidationMode { AUTO, CALLBACK, NONE};
+ </xsd:documentation>
+ </xsd:annotation>
+ <xsd:restriction base="xsd:token">
+ <xsd:enumeration value="AUTO"/>
+ <xsd:enumeration value="CALLBACK"/>
+ <xsd:enumeration value="NONE"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+</xsd:schema>
\ No newline at end of file
Added: jpamodelgen/trunk/generator/src/test/resources/META-INF/jpa1-orm.xml
===================================================================
--- jpamodelgen/trunk/generator/src/test/resources/META-INF/jpa1-orm.xml
(rev 0)
+++ jpamodelgen/trunk/generator/src/test/resources/META-INF/jpa1-orm.xml 2009-07-10
16:23:22 UTC (rev 17070)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
orm_1_0.xsd"
+ version="1.0"
+ >
+ <package>model</package>
+ <entity class="Airplane" metadata-complete="true"
access="PROPERTY">
+ <attributes>
+ <id name="serialNumber"/>
+ </attributes>
+ </entity>
+</entity-mappings>
\ No newline at end of file
Copied: jpamodelgen/trunk/generator/src/test/resources/META-INF/malformed-mapping-xml.xml
(from rev 17064, jpamodelgen/trunk/generator/src/test/resources/META-INF/dummy.xml)
===================================================================
--- jpamodelgen/trunk/generator/src/test/resources/META-INF/malformed-mapping-xml.xml
(rev 0)
+++
jpamodelgen/trunk/generator/src/test/resources/META-INF/malformed-mapping-xml.xml 2009-07-10
16:23:22 UTC (rev 17070)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<entity-mappings
xmlns="http://java.sun.com/xml/ns/persistence/orm"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
orm_2_0.xsd"
+ version="2.0"
+ >
+ <package>model</package>
+ <entity class="Dummy" access="FIELD"
metadata-complete="true"> <!-- Class does not exist -->
+ <attributes>
+ <id name="id"/>
+ </entity>
+</entity-mappings>
Modified: jpamodelgen/trunk/generator/src/test/resources/META-INF/order.xml
===================================================================
--- jpamodelgen/trunk/generator/src/test/resources/META-INF/order.xml 2009-07-10 16:02:57
UTC (rev 17069)
+++ jpamodelgen/trunk/generator/src/test/resources/META-INF/order.xml 2009-07-10 16:23:22
UTC (rev 17070)
@@ -5,7 +5,8 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm
orm_2_0.xsd"
version="2.0"
- <package>model</package> <!-- default
package -->
+ <package>model</package>
+ <!-- default package -->
<entity class="Order" access="FIELD"
metadata-complete="true"> <!--means ignore annotations-->
<attributes>
<id name="id">
@@ -13,24 +14,16 @@
</id>
<basic name="filled"/>
<basic name="date"/>
- <one-to-many name="items" target-entity="Item"
fetch="EAGER"> <!-- target-entity optional guess the type from the
geenric-->
+ <many-to-one name="shop"/>
+ <one-to-many name="items"
+ target-entity="Item"
+ fetch="EAGER"> <!-- target-entity optional guess
the type from the geenric-->
<cascade>
<cascade-persist/>
</cascade>
</one-to-many>
- <many-to-one name="shop"/>
- <element-collection name="notes"/> <!-- new in JPA 2
-->
+ <element-collection name="notes"/>
+ <!-- new in JPA 2 -->
</attributes>
</entity>
</entity-mappings>
-
-
- <!--
-public class Order {
- long id;
- Set<Item> items;
- boolean filled;
- Date date;
- List<String> notes;
- Shop shop;
-} -->
\ No newline at end of file
Modified: jpamodelgen/trunk/generator/src/test/resources/META-INF/persistence.xml
===================================================================
--- jpamodelgen/trunk/generator/src/test/resources/META-INF/persistence.xml 2009-07-10
16:02:57 UTC (rev 17069)
+++ jpamodelgen/trunk/generator/src/test/resources/META-INF/persistence.xml 2009-07-10
16:23:22 UTC (rev 17070)
@@ -6,6 +6,8 @@
<description>Test persistence unit</description>
<mapping-file>/META-INF/order.xml</mapping-file>
<mapping-file>/META-INF/dummy.xml</mapping-file>
+ <mapping-file>/META-INF/malformed-mapping-xml.xml</mapping-file>
+ <mapping-file>/META-INF/jpa1-orm.xml</mapping-file>
<mapping-file>/model/xmlmapped/address.xml</mapping-file>
<mapping-file>/model/xmlmapped/building.xml</mapping-file>
<mapping-file>/model/xmlmapped/mammal.xml</mapping-file>