OPENJPA-823 Added new 2.0 schemas and updated persistence and metadata parsers to use per-version schema validation

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@726144 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jeremy Bauer 2008-12-12 22:36:30 +00:00
parent debe82b8d0
commit c1d791f6dd
13 changed files with 2203 additions and 7 deletions

View File

@ -0,0 +1,85 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
package org.apache.openjpa.lib.meta;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
* Custom non-validating SAX parser which can be used to get the version and
* schema location attributes from the root node.
*
* @author Jeremy Bauer
* @nojavadoc
*/
public class XMLVersionParser extends XMLMetaDataParser {
public static final String VERSION_1_0 = "1.0";
public static final String VERSION_2_0 = "2.0";
static private final String VERSION_ATTR = "version";
static private final String XSI_NS =
"http://www.w3.org/2001/XMLSchema-instance";
static private final String SCHEMA_LOCATION = "schemaLocation";
private String _rootElement;
private String _version;
private String _schemaLocation;
public XMLVersionParser(String rootElement) {
_rootElement = rootElement;
setCaching(false);
setValidating(false);
setParseText(false);
}
@Override
protected void endElement(String name) throws SAXException {
}
@Override
protected boolean startElement(String name, Attributes attrs)
throws SAXException {
if (name.equals(_rootElement)) {
// save the version and schema location attributes
_version = attrs.getValue("", VERSION_ATTR);
_schemaLocation = attrs.getValue(XSI_NS, SCHEMA_LOCATION);
// ignore remaining content
ignoreContent(true);
}
return false;
}
/**
* Get the string value of the version attribute on the root element
* @return doc version
*/
public String getVersion() {
return _version;
}
/**
* Get the string value of the schema location attribute on the root element
* @return doc schema location
*/
public String getSchemaLocation() {
return _schemaLocation;
}
}

View File

@ -0,0 +1,100 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
package org.apache.openjpa.persistence.xml;
import junit.framework.TestCase;
import org.apache.openjpa.persistence.OpenJPAEntityManager;
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
import org.apache.openjpa.persistence.OpenJPAPersistence;
public class TestSchemaVersionValidation extends TestCase {
/**
* Verify a pu can be created with a version 2.0 persistence.xml
*/
public void test2_0PersistenceXml() {
OpenJPAEntityManagerFactory emf = OpenJPAPersistence.
createEntityManagerFactory("XSDTest",
"org/apache/openjpa/persistence/xml/persistence-2_0.xml");
emf.close();
}
/**
* Verify schema validation will fail when using a 2.0
* persistence.xml that does not contain a persistence unit
* (the 2.0 spec made it a requirement for the persistence file
* to contain at least one pu.)
*/
public void testBad2_0PersistenceXml() {
try {
OpenJPAEntityManagerFactory emf = OpenJPAPersistence.
createEntityManagerFactory(null,
"org/apache/openjpa/persistence/xml/persistence-2_0-no-pu.xml");
emf.close();
fail();
} catch (Exception e) {
assert(!e.getMessage().contains("SAXException"));
}
}
/**
* Verify a version 2.0 persistence.xml can reference and the provider
* can parse a version 1.0 orm.xml
*/
public void test2_0Persistence1_0OrmXml() {
OpenJPAEntityManagerFactory emf = OpenJPAPersistence.
createEntityManagerFactory("XSDTest",
"org/apache/openjpa/persistence/xml/" +
"persistence-2_0-orm-1_0.xml");
OpenJPAEntityManager em = emf.createEntityManager();
em.close();
emf.close();
}
/**
* Verify a version 2.0 persistence.xml can reference and the provider can
* parse a version 2.0 orm.xml
*/
public void test2_0Persistence2_0OrmXml() {
OpenJPAEntityManagerFactory emf = OpenJPAPersistence.
createEntityManagerFactory("XSDTest",
"org/apache/openjpa/persistence/xml/" +
"persistence-2_0-orm-2_0.xml");
OpenJPAEntityManager em = emf.createEntityManager();
em.close();
emf.close();
}
/**
* Verify a 1.0 persistence.xml can include a 2.0 orm.xml
*/
public void test1_0Persistence2_0OrmXml() {
OpenJPAEntityManagerFactory emf = OpenJPAPersistence.
createEntityManagerFactory("XSDTest",
"org/apache/openjpa/persistence/xml/" +
"persistence-2_0-orm-1_0.xml");
OpenJPAEntityManager em = emf.createEntityManager();
em.close();
emf.close();
}
}

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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">
<persistence-unit-metadata>
<persistence-unit-defaults/>
<description> This is an orm 2.0 element</description>
</persistence-unit-defaults>
</persistence-unit-metadata>
<package>
org.apache.openjpa.persistence.xml
</package>
<entity name="SimpleXml" class="SimpleXmlEntity">
<named-query name="SimpleXml.findAll">
<query>select o from SimpleXml o</query>
</named-query>
<named-query name="SimpleXmlEntity.findAll">
<query>select o from SimpleXmlEntity o</query>
</named-query>
<attributes>
<id name="id">
<generated-value generator="uuid-hex"/>
</id>
<basic name="stringField"/>
<version name="version"/>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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_1_0.xsd"
version="1.0" >
<persistence-unit name="XSDTest" transaction-type="RESOURCE_LOCAL">
<description>PU for schema validation testing</description>
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<mapping-file>org/apache/openjpa/persistence/xml/orm_2_0.xml</mapping-file>
</persistence-unit>
</persistence>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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" >
<!-- The 2.0 schema requires a persistence unit to be defined. Schema validation should fail. -->
</persistence>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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-unit name="XSDTest" transaction-type="RESOURCE_LOCAL">
<description>PU for schema validation testing</description>
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<mapping-file>org/apache/openjpa/persistence/xml/orm.xml</mapping-file>
</persistence-unit>
</persistence>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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-unit name="XSDTest" transaction-type="RESOURCE_LOCAL">
<description>PU for schema validation testing</description>
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<mapping-file>org/apache/openjpa/persistence/xml/orm_2_0.xml</mapping-file>
</persistence-unit>
</persistence>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you 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.
-->
<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-unit name="XSDTest" transaction-type="RESOURCE_LOCAL">
<description>PU for schema validation testing</description>
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
</persistence-unit>
</persistence>

View File

@ -45,6 +45,7 @@ import org.apache.openjpa.lib.conf.MapConfigurationProvider;
import org.apache.openjpa.lib.conf.ProductDerivations;
import org.apache.openjpa.lib.log.Log;
import org.apache.openjpa.lib.meta.XMLMetaDataParser;
import org.apache.openjpa.lib.meta.XMLVersionParser;
import org.apache.openjpa.lib.util.J2DoPrivHelper;
import org.apache.openjpa.lib.util.Localizer;
import org.xml.sax.Attributes;
@ -491,9 +492,17 @@ public class PersistenceProductDerivation
public static class ConfigurationParser
extends XMLMetaDataParser {
private static final String PERSISTENCE_XSD_1_0 = "persistence_1_0.xsd";
private static final String PERSISTENCE_XSD_2_0 = "persistence_2_0.xsd";
private static final Localizer _loc = Localizer.forPackage
(ConfigurationParser.class);
private final Map _map;
private PersistenceUnitInfoImpl _info = null;
private URL _source = null;
private String _persistenceVersion;
private String _schemaLocation;
public ConfigurationParser(Map map) {
_map = map;
@ -506,6 +515,17 @@ public class PersistenceProductDerivation
public void parse(URL url)
throws IOException {
_source = url;
// peek at the doc to determine the version
XMLVersionParser vp = new XMLVersionParser("persistence");
try {
vp.parse(url);
_persistenceVersion = vp.getVersion();
_schemaLocation = vp.getSchemaLocation();
} catch (Throwable t) {
log(_loc.get("version-check-error",
_source.toString()).toString());
}
super.parse(url);
}
@ -518,12 +538,36 @@ public class PersistenceProductDerivation
} catch (PrivilegedActionException pae) {
throw (MalformedURLException) pae.getException();
}
// peek at the doc to determine the version
XMLVersionParser vp = new XMLVersionParser("persistence");
try {
vp.parse(file);
_persistenceVersion = vp.getVersion();
_schemaLocation = vp.getSchemaLocation();
} catch (Throwable t) {
log(_loc.get("version-check-error",
_source.toString()).toString());
}
super.parse(file);
}
@Override
protected Object getSchemaSource() {
return getClass().getResourceAsStream("persistence-xsd.rsrc");
// use the version 1 schema by default. non-versioned docs will
// continue to parse with the old xml if they do not contain a
// persistence-unit. that is currently the only signficant change
// to the schema. if more significant changes are made in the
// future, the 2.0 schema may be preferable.
String persistencexsd = "persistence-xsd.rsrc";
// if the version and/or schema location is for 1.0, use the 1.0
// schema
if (_persistenceVersion != null &&
_persistenceVersion.equals(XMLVersionParser.VERSION_2_0) ||
(_schemaLocation != null &&
_schemaLocation.indexOf(PERSISTENCE_XSD_2_0) != -1)) {
persistencexsd = "persistence_2_0-xsd.rsrc";
}
return getClass().getResourceAsStream(persistencexsd);
}
@Override

View File

@ -18,9 +18,12 @@
*/
package org.apache.openjpa.persistence;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.util.ArrayList;
@ -31,7 +34,6 @@ import java.util.Map;
import java.util.Set;
import java.util.Stack;
import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.GenerationType;
import static javax.persistence.CascadeType.*;
@ -50,6 +52,7 @@ import org.apache.openjpa.kernel.jpql.JPQLParser;
import org.apache.openjpa.lib.conf.Configurations;
import org.apache.openjpa.lib.log.Log;
import org.apache.openjpa.lib.meta.CFMetaDataParser;
import org.apache.openjpa.lib.meta.XMLVersionParser;
import org.apache.openjpa.lib.util.J2DoPrivHelper;
import org.apache.openjpa.lib.util.Localizer;
import org.apache.openjpa.meta.ClassMetaData;
@ -68,8 +71,6 @@ import org.apache.openjpa.meta.ValueMetaData;
import static org.apache.openjpa.persistence.MetaDataTag.*;
import static org.apache.openjpa.persistence.PersistenceStrategy.*;
import org.apache.openjpa.util.ImplHelper;
import org.apache.openjpa.util.MetaDataException;
import serp.util.Numbers;
/**
@ -182,6 +183,12 @@ public class XMLPersistenceMetaDataParser
private int[] _highs = null;
private boolean _isXMLMappingMetaDataComplete = false;
private String _ormVersion;
private String _schemaLocation;
private static final String ORM_XSD_1_0 = "orm_1_0.xsd";
private static final String ORM_XSD_2_0 = "orm_2_0.xsd";
/**
* Constructor; supply configuration.
*/
@ -311,6 +318,37 @@ public class XMLPersistenceMetaDataParser
_parser.setMode(mode);
}
public void parse(URL url) throws IOException {
// peek at the doc to determine the version
XMLVersionParser vp = new XMLVersionParser("entity-mappings");
try {
vp.parse(url);
_ormVersion = vp.getVersion();
_schemaLocation = vp.getSchemaLocation();
} catch (Throwable t) {
Log log = getLog();
if (log.isInfoEnabled())
log.trace(_loc.get("version-check-error",
url.toString()));
}
super.parse(url);
}
public void parse(File file) throws IOException {
// peek at the doc to determine the version
XMLVersionParser vp = new XMLVersionParser("entity-mappings");
try {
vp.parse(file);
_ormVersion = vp.getVersion();
_schemaLocation = vp.getSchemaLocation();
} catch (Throwable t) {
Log log = getLog();
if (log.isInfoEnabled())
log.trace(_loc.get("version-check-error",
file.toString()));
}
super.parse(file);
}
/**
* Convenience method for interpreting {@link #getMode}.
*/
@ -400,9 +438,19 @@ public class XMLPersistenceMetaDataParser
}
@Override
protected Object getSchemaSource() {
return XMLPersistenceMetaDataParser.class.getResourceAsStream
("orm-xsd.rsrc");
protected Object getSchemaSource() {
// use the latest schema by default. 'unknown' docs should parse
// with the latest schema.
String ormxsd = "orm_2_0-xsd.rsrc";
// if the version and/or schema location is for 1.0, use the 1.0
// schema
if (_ormVersion != null &&
_ormVersion.equals(XMLVersionParser.VERSION_1_0) ||
(_schemaLocation != null &&
_schemaLocation.indexOf(ORM_XSD_1_0) != -1)) {
ormxsd = "orm-xsd.rsrc";
}
return XMLPersistenceMetaDataParser.class.getResourceAsStream(ormxsd);
}
@Override

View File

@ -161,4 +161,6 @@ param-type-mismatch: Parameter "{0}" declared in "{1}" is set to value of \
"{2}" of type "{3}", but this parameter is bound to a field of type "{4}".
param-type-null: Parameter "{0}" declared in "{1}" is set to null, \
but this parameter is bound to a field of primitive type "{2}".
version-check-error: An error occurred while attempting to determine the \
version of "{0}".

View File

@ -0,0 +1,221 @@
<?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="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:schema>