<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~ Hibernate, Relational Persistence for Idiomatic Java
  ~
  ~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
  ~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
  -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="http://www.hibernate.org/xsd/orm/hbm"
           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
           xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
           targetNamespace="http://www.hibernate.org/xsd/orm/hbm"
           elementFormDefault="qualified"
           jaxb:extensionBindingPrefixes="simplify"
           jaxb:version="1.0"
           version="4.0">
    <xs:annotation>
        <xs:documentation>
            This document defines the legacy Hibernate mapping schema.  The root element in
            such mappings is the hibernate-mapping element.
        </xs:documentation>
    </xs:annotation>

    <xs:element name="hibernate-mapping">
        <xs:annotation>
            <xs:documentation>
                The document root.
            </xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:complexContent>
                <xs:extension base="ToolingHintContainer">
                    <xs:choice minOccurs="1" maxOccurs="unbounded">
                        <xs:annotation>
                            <xs:appinfo>
                                <simplify:as-element-property/>
                            </xs:appinfo>
                        </xs:annotation>
                        <xs:element name="identifier-generator" type="IdentifierGeneratorDefinitionType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="typedef" type="TypeDefinitionType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:element name="filter-def" type="FilterDefinitionType" minOccurs="0" maxOccurs="unbounded"/>

                        <xs:element name="import" type="ClassRenameType" minOccurs="0" maxOccurs="unbounded"/>

                        <xs:element name="class" type="RootEntityType"/>
                        <xs:element name="subclass" type="DiscriminatorSubclassEntityType"/>
                        <xs:element name="joined-subclass" type="JoinedSubclassEntityType"/>
                        <xs:element name="union-subclass" type="UnionSubclassEntityType"/>

                        <xs:element name="resultset" type="ResultSetMappingType" minOccurs="0" maxOccurs="unbounded"/>
                        <xs:group ref="NamedQueryGroup" minOccurs="0" maxOccurs="unbounded"/>

                        <xs:element name="fetch-profile" type="FetchProfileType" minOccurs="0" maxOccurs="unbounded"/>

                        <xs:element name="database-object" type="AuxiliaryDatabaseObjectType" minOccurs="0" maxOccurs="unbounded"/>
                    </xs:choice>

                    <xs:attribute name="auto-import" default="true" type="xs:boolean"/>
                    <xs:attribute name="catalog" type="xs:string"/>
                    <!-- default: none -->
                    <xs:attribute name="default-access" default="property" type="xs:string"/>
                    <xs:attribute name="default-cascade" default="none" type="xs:string"/>
                    <xs:attribute name="default-lazy" default="true" type="xs:boolean"/>
                    <xs:attribute name="package" type="ClassNameType"/>
                    <xs:attribute name="schema" type="xs:string"/>
                </xs:extension>
            </xs:complexContent>

        </xs:complexType>
    </xs:element>

    <xs:complexType name="ToolingHintContainer" abstract="true">
        <xs:annotation>
            <xs:documentation>
                Describes an XSD base type for any complex type that can contain "tooling hints".
            </xs:documentation>
        </xs:annotation>
        <xs:choice>
            <xs:element name="meta" type="ToolingHintType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:choice>
    </xs:complexType>

    <xs:complexType name="ToolingHintType" mixed="true">
        <xs:annotation>
            <xs:documentation><![CDATA[
                <meta.../> is used to assign meta-level attributes to a class
                or property.  Is currently used by tooling as a placeholder for
                values that is not directly related to OR mappings.

                Example: <meta attribute="someHintName">the-hint-value</meta>
            ]]></xs:documentation>
        </xs:annotation>
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="attribute" use="required" type="xs:string"/>
                <xs:attribute name="inherit" default="true" type="xs:boolean"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:complexType name="IdentifierGeneratorDefinitionType">
        <xs:attribute name="class" use="required" type="ClassNameType"/>
        <xs:attribute name="name" use="required" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="TypeDefinitionType">
        <xs:complexContent>
            <xs:extension base="ConfigParameterContainer">
                <xs:attribute name="class" use="required" type="ClassNameType"/>
                <xs:attribute name="name" use="required" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="FilterDefinitionType" mixed="true">
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:element name="filter-param" type="FilterParameterType"/>
        </xs:sequence>
        <xs:attribute name="condition" type="xs:string"/>
        <xs:attribute name="name" use="required" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="FilterParameterType">
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="type" use="required" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="ClassRenameType">
        <xs:attribute name="class" use="required" type="ClassNameType"/>
        <xs:attribute name="rename" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="AuxiliaryDatabaseObjectType">
        <xs:sequence>
            <xs:choice>
                <xs:element name="definition">
                    <xs:complexType>
                        <xs:attribute name="class" use="required" type="ClassNameType"/>
                    </xs:complexType>
                </xs:element>
                <xs:sequence>
                    <xs:element name="create" type="xs:string"/>
                    <xs:element name="drop" type="xs:string"/>
                </xs:sequence>
            </xs:choice>
            <xs:element name="dialect-scope" minOccurs="0" maxOccurs="unbounded" type="DialectScopeType"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="DialectScopeType" mixed="true">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="name" use="required" type="xs:string"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:complexType name="FetchProfileType">
        <xs:sequence>
            <xs:element name="fetch" minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation><![CDATA[
                        The <fetch> element defines a single path to which the fetch
                        refers, as well as the style of fetch to apply.  The 'root' of the
                        path is different depending upon the context in which the
                        containing <fetch-profile/> occurs; within a <class/> element,
                        the entity-name of the containing class mapping is assumed...
                        ]]></xs:documentation>
                </xs:annotation>
                <xs:complexType>
                    <xs:attribute name="association" use="required" type="xs:string"/>
                    <xs:attribute name="entity" type="xs:string"/>
                    <!-- Implied as long as the containing fetch profile is contained in a class mapping -->
                    <xs:attribute name="style" default="join" type="FetchStyleEnum">

                    </xs:attribute>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="name" use="required" type="xs:string"/>
    </xs:complexType>



    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Named queries -->
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

    <xs:group name="NamedQueryGroup">
        <xs:choice>
            <xs:element name="query" type="NamedQueryType"/>
            <xs:element name="sql-query" type="NamedNativeQueryType"/>
        </xs:choice>
    </xs:group>

    <xs:complexType name="NamedQueryType" mixed="true">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="query-param" type="QueryParamType"/>
        </xs:choice>
        <xs:attribute name="cache-mode" type="CacheModeEnum"/>
        <xs:attribute name="cache-region" type="xs:string"/>
        <xs:attribute name="cacheable" default="false" type="xs:boolean"/>
        <xs:attribute name="comment" type="xs:string"/>
        <xs:attribute name="fetch-size" type="xs:int"/>
        <xs:attribute name="flush-mode" type="FlushModeEnum"/>
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="read-only" default="false" type="xs:boolean"/>
        <xs:attribute name="timeout" type="xs:int"/>
    </xs:complexType>

    <xs:complexType name="NamedNativeQueryType" mixed="true">
        <xs:annotation>
            <xs:documentation>
                The sql-query element declares a named SQL query string
            </xs:documentation>
        </xs:annotation>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="query-param" type="QueryParamType"/>
            <xs:group ref="NativeQueryReturnGroup"/>
            <xs:element name="synchronize" type="synchronize-type"/>
        </xs:choice>
        <xs:attribute name="cache-mode" type="CacheModeEnum"/>
        <xs:attribute name="cache-region" type="xs:string"/>
        <xs:attribute name="cacheable" default="false" type="xs:boolean"/>
        <xs:attribute name="comment" type="xs:string"/>
        <xs:attribute name="fetch-size" type="xs:int"/>
        <xs:attribute name="flush-mode" type="FlushModeEnum"/>
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="read-only" default="false" type="xs:boolean"/>
        <xs:attribute name="timeout" type="xs:int"/>
        <xs:attribute name="callable" default="false" type="xs:boolean"/>
        <xs:attribute name="resultset-ref" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="QueryParamType">
        <xs:annotation>
            <xs:documentation>
                The query-param element is used only by tools that generate
                finder methods for named queries
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="type" use="required" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="ResultSetMappingType">
        <xs:annotation>
            <xs:documentation>
                The resultset element declares a named resultset mapping definition for SQL queries
            </xs:documentation>
        </xs:annotation>

        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:annotation>
                <xs:appinfo>
                    <jaxb:property name="valueMappingSources"/>
                </xs:appinfo>
            </xs:annotation>
            <!--
                Do *not* apply simplify to this.  The ordering amongst the elements IS IMPORTANT
             -->
            <xs:group ref="NativeQueryReturnGroup"/>
        </xs:choice>
        <xs:attribute name="name" use="required" type="xs:string"/>
    </xs:complexType>

    <xs:group name="NativeQueryReturnGroup">
        <xs:choice>
            <xs:element name="return-scalar" type="NativeQueryScalarReturnType"/>
            <xs:element name="return" type="NativeQueryReturnType"/>
            <xs:element name="return-join" type="NativeQueryJoinReturnType"/>
            <xs:element name="load-collection" type="NativeQueryCollectionLoadReturnType"/>
        </xs:choice>
    </xs:group>

    <xs:complexType name="NativeQueryScalarReturnType">
        <xs:attribute name="column" use="required" type="xs:string"/>
        <xs:attribute name="type" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="NativeQueryReturnType">
        <xs:annotation>
            <xs:documentation>
                Defines a return component for a sql-query. Alias refers to the alias
                used in the actual sql query; lock-mode specifies the locking to be applied
                when the query is executed. The class, collection, and role attributes are mutually exclusive;
                class refers to the class name of a "root entity" in the object result; collection refers
                to a collection of a given class and is used to define custom sql to load that owned collection
                and takes the form "ClassName.propertyName"; role refers to the property path for an eager fetch
                and takes the form "owningAlias.propertyName"
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="return-discriminator" minOccurs="0">
                <xs:complexType>
                    <xs:attribute name="column" use="required" type="xs:string"/>
                </xs:complexType>
            </xs:element>
            <xs:element name="return-property" type="NativeQueryPropertyReturnType" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="alias" type="xs:string"/>
        <xs:attribute name="class" type="ClassNameType"/>
        <xs:attribute name="entity-name" type="xs:string"/>
        <xs:attribute name="lock-mode" default="read" type="LockModeEnum"/>
    </xs:complexType>

    <xs:complexType name="NativeQueryPropertyReturnType">
        <xs:sequence>
            <xs:element name="return-column" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:attribute name="name" use="required" type="xs:string"/>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="column" type="xs:string"/>
        <xs:attribute name="name" use="required" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="NativeQueryJoinReturnType">
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:element name="return-property" type="NativeQueryPropertyReturnType"/>
        </xs:sequence>
        <xs:attribute name="alias" use="required" type="xs:string"/>
        <xs:attribute name="lock-mode" default="read" type="LockModeEnum"/>
        <xs:attribute name="property" use="required" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="NativeQueryCollectionLoadReturnType">
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:element name="return-property" type="NativeQueryPropertyReturnType"/>
        </xs:sequence>
        <xs:attribute name="alias" use="required" type="xs:string"/>
        <xs:attribute name="lock-mode" default="read" type="LockModeEnum"/>
        <xs:attribute name="role" use="required" type="xs:string"/>
    </xs:complexType>


    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Entity definitions -->
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

    <xs:complexType name="EntityBaseDefinition" abstract="true">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:attribute name="name" type="ClassNameType"/>
                <xs:attribute name="entity-name" type="xs:string"/>
                <xs:attribute name="abstract" type="xs:boolean"/>
                <!-- default: none when toplevel, otherwise the nearest class definition -->
                <xs:attribute name="lazy" type="xs:boolean"/>
                <xs:attribute name="proxy" type="ClassNameType"/>
                <xs:attribute name="batch-size" default="-1" type="xs:int"/>
                <!-- default: none -->
                <xs:attribute name="dynamic-insert" default="false" type="xs:boolean"/>
                <xs:attribute name="dynamic-update" default="false" type="xs:boolean"/>
                <!-- default: no proxy interface -->
                <xs:attribute name="select-before-update" default="false" type="xs:boolean"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="persister" type="ClassNameType"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="SubclassEntityBaseDefinition" abstract="true">
        <xs:complexContent>
            <xs:extension base="EntityBaseDefinition">
                <xs:attribute name="extends" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="RootEntityType">
        <xs:annotation>
            <xs:documentation>
                Root entity mapping. Poorly named as entities do not have to be represented by
                classes at all. Mapped entities may be represented via different methodologies
                (POJO, Map, Dom4j).
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="EntityBaseDefinition">
                <xs:sequence>
                    <xs:element name="tuplizer" minOccurs="0" maxOccurs="unbounded" type="tuplizer-type"/>
                    <xs:element name="subselect" minOccurs="0" type="xs:string"/>
                    <xs:element name="cache" minOccurs="0" type="CacheType"/>
                    <xs:element name="natural-id-cache" minOccurs="0" type="NaturalIdCacheType"/>
                    <xs:element name="synchronize" minOccurs="0" maxOccurs="unbounded" type="synchronize-type"/>
                    <!-- The comment element allows definition of a database table or column comment. -->
                    <xs:element name="comment" minOccurs="0" type="xs:string"/>

                    <xs:choice>
                        <xs:element name="id" type="SimpleIdType"/>
                        <xs:element name="composite-id" type="CompositeIdType"/>
                    </xs:choice>
                    <xs:element name="discriminator" minOccurs="0" type="EntityDiscriminatorType"/>
                    <xs:element name="natural-id" minOccurs="0" type="natural-id-type"/>
                    <xs:choice minOccurs="0">
                        <xs:element name="version" type="VersionAttributeType"/>
                        <xs:element name="timestamp" type="TimestampAttributeType"/>
                    </xs:choice>
                    <xs:element name="multi-tenancy" minOccurs="0" type="multi-tenancy-type"/>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:annotation>
                            <xs:appinfo>
                                <jaxb:property name="attributes" />
                                <!--<simplify:as-element-property/>-->
                            </xs:appinfo>
                        </xs:annotation>
                        <xs:element name="idbag" type="IdBagCollectionType"/>
                        <xs:group ref="SingularAttributeGroup"/>
                    </xs:choice>
                    <xs:choice>
                        <xs:sequence>
                            <xs:element name="join" minOccurs="0" maxOccurs="unbounded" type="SecondaryTableType"/>
                            <xs:element name="subclass" minOccurs="0" maxOccurs="unbounded" type="DiscriminatorSubclassEntityType"/>
                        </xs:sequence>
                        <xs:element name="joined-subclass"
                                    minOccurs="0"
                                    maxOccurs="unbounded"
                                    type="JoinedSubclassEntityType"/>
                        <xs:element name="union-subclass"
                                    minOccurs="0"
                                    maxOccurs="unbounded"
                                    type="UnionSubclassEntityType"/>
                    </xs:choice>
                    <xs:element name="loader" minOccurs="0" type="loader-type"/>
                    <xs:group ref="CustomSqlDmlGroup"/>
                    <xs:element name="filter" minOccurs="0" maxOccurs="unbounded" type="filter-type"/>
                    <xs:element name="fetch-profile" minOccurs="0" maxOccurs="unbounded" type="FetchProfileType"/>
                    <xs:element name="resultset" minOccurs="0" maxOccurs="unbounded" type="ResultSetMappingType"/>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:annotation>
                            <xs:appinfo>
                                <simplify:as-element-property/>
                            </xs:appinfo>
                        </xs:annotation>
                        <xs:group ref="NamedQueryGroup"/>
                    </xs:choice>
                </xs:sequence>
                <xs:attribute name="catalog" type="xs:string"/>
                <xs:attribute name="check" type="xs:string"/>
                <xs:attribute name="discriminator-value" type="xs:string"/>
                <xs:attribute name="mutable" default="true" type="xs:boolean"/>
                <xs:attribute name="optimistic-lock" default="version" type="OptimisticLockStyleEnum"/>
                <xs:attribute name="polymorphism" default="implicit" type="PolymorphismEnum"/>
                <xs:attribute name="rowid" type="xs:string"/>
                <xs:attribute name="schema" type="xs:string"/>
                <xs:attribute name="subselect" type="xs:string"/>
                <xs:attribute name="table" type="xs:string"/>
                <xs:attribute name="where" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="JoinedSubclassEntityType">
        <xs:annotation>
            <xs:documentation><![CDATA[
                Joined subclasses are used for the normalized table-per-subclass mapping strategy
                See the note on the class element regarding <pojo/> vs. @name usage...
            ]]></xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="SubclassEntityBaseDefinition">
                <xs:sequence>
                    <xs:element name="tuplizer" minOccurs="0" maxOccurs="unbounded" type="tuplizer-type"/>
                    <xs:element name="subselect" minOccurs="0" type="xs:string"/>
                    <xs:element name="synchronize" minOccurs="0" maxOccurs="unbounded" type="synchronize-type"/>
                    <!-- The comment element allows definition of a database table or column comment. -->
                    <xs:element name="comment" minOccurs="0" type="xs:string"/>
                    <xs:element name="key" type="key-type"/>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:annotation>
                            <xs:appinfo>
                                <jaxb:property name="attributes" />
                                <!--<simplify:as-element-property/>-->
                            </xs:appinfo>
                        </xs:annotation>
                        <xs:group ref="SingularAttributeGroup"/>
                        <xs:element name="idbag" type="IdBagCollectionType"/>
                    </xs:choice>
                    <xs:element name="joined-subclass"
                                minOccurs="0"
                                maxOccurs="unbounded"
                                type="JoinedSubclassEntityType"/>
                    <xs:element name="loader" minOccurs="0" type="loader-type"/>
                    <xs:group ref="CustomSqlDmlGroup" minOccurs="0"/>
                    <xs:element name="fetch-profile" minOccurs="0" maxOccurs="unbounded" type="FetchProfileType"/>
                    <xs:element name="resultset" minOccurs="0" maxOccurs="unbounded" type="ResultSetMappingType"/>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:annotation>
                            <xs:appinfo>
                                <simplify:as-element-property/>
                            </xs:appinfo>
                        </xs:annotation>
                        <xs:group ref="NamedQueryGroup"/>
                    </xs:choice>
                </xs:sequence>
                <xs:attributeGroup ref="table-information-group"/>
                <xs:attribute name="check" type="xs:string"/>
                <xs:attribute name="discriminator-value" type="xs:string" />
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="UnionSubclassEntityType">
        <xs:annotation>
            <xs:documentation><![CDATA[
                Union subclasses are used for the table-per-concrete-class mapping strategy
                See the note on the class element regarding <pojo/> vs. @name usage...
            ]]></xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="SubclassEntityBaseDefinition">
                <xs:sequence>
                    <xs:element name="tuplizer" minOccurs="0" maxOccurs="unbounded" type="tuplizer-type"/>
                    <xs:element name="subselect" minOccurs="0" type="xs:string"/>
                    <xs:element name="synchronize" minOccurs="0" maxOccurs="unbounded" type="synchronize-type"/>
                    <!-- The comment element allows definition of a database table or column comment. -->
                    <xs:element name="comment" minOccurs="0" type="xs:string"/>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:annotation>
                            <xs:appinfo>
                                <jaxb:property name="attributes" />
                                <!--<simplify:as-element-property/>-->
                            </xs:appinfo>
                        </xs:annotation>
                        <xs:element name="idbag" type="IdBagCollectionType"/>
                        <xs:group ref="SingularAttributeGroup"/>
                    </xs:choice>
                    <xs:element name="union-subclass"
                                minOccurs="0"
                                maxOccurs="unbounded"
                                type="UnionSubclassEntityType"/>
                    <xs:element name="loader" minOccurs="0" type="loader-type"/>
                    <xs:group ref="CustomSqlDmlGroup" minOccurs="0"/>
                    <xs:element name="fetch-profile" minOccurs="0" maxOccurs="unbounded" type="FetchProfileType"/>
                    <xs:element name="resultset" minOccurs="0" maxOccurs="unbounded" type="ResultSetMappingType"/>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:annotation>
                            <xs:appinfo>
                                <simplify:as-element-property/>
                            </xs:appinfo>
                        </xs:annotation>
                        <xs:group ref="NamedQueryGroup"/>
                    </xs:choice>
                </xs:sequence>
                <xs:attributeGroup ref="table-information-group"/>
                <xs:attribute name="check" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="DiscriminatorSubclassEntityType">
        <xs:annotation>
            <xs:documentation><![CDATA[
                Subclass declarations are nested beneath the root class declaration to achieve
                polymorphic persistence with the table-per-hierarchy mapping strategy.
                See the note on the class element regarding <pojo/> vs. @name usage...
            ]]></xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="SubclassEntityBaseDefinition">
                <xs:sequence>
                    <xs:element name="tuplizer" minOccurs="0" maxOccurs="unbounded" type="tuplizer-type"/>
                    <xs:element name="synchronize" minOccurs="0" maxOccurs="unbounded" type="synchronize-type"/>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:annotation>
                            <xs:appinfo>
                                <jaxb:property name="attributes" />
                                <!--<simplify:as-element-property/>-->
                            </xs:appinfo>
                        </xs:annotation>
                        <xs:group ref="SingularAttributeGroup"/>
                        <xs:element name="idbag" type="IdBagCollectionType"/>
                    </xs:choice>
                    <xs:element name="join" minOccurs="0" maxOccurs="unbounded" type="SecondaryTableType"/>
                    <xs:element name="subclass" minOccurs="0" maxOccurs="unbounded" type="DiscriminatorSubclassEntityType"/>
                    <xs:element name="loader" minOccurs="0" type="loader-type"/>
                    <xs:group ref="CustomSqlDmlGroup" minOccurs="0"/>
                    <xs:element name="fetch-profile" minOccurs="0" maxOccurs="unbounded" type="FetchProfileType"/>
                    <xs:element name="resultset" minOccurs="0" maxOccurs="unbounded" type="ResultSetMappingType"/>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:annotation>
                            <xs:appinfo>
                                <simplify:as-element-property/>
                            </xs:appinfo>
                        </xs:annotation>
                        <xs:group ref="NamedQueryGroup"/>
                    </xs:choice>
                </xs:sequence>
                <xs:attribute name="discriminator-value" type="xs:string" />
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="SimpleIdType">
        <xs:annotation>
            <xs:documentation>
                Declares the id type, column and generation algorithm for an entity class.
                If a name attribute is given, the id is exposed to the application through the
                named property of the class. If not, the id is only exposed to the application
                via Session.getIdentifier()
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="column" minOccurs="0" maxOccurs="unbounded" type="ColumnType"/>
                    <xs:element name="type" minOccurs="0" type="TypeSpecificationType"/>
                    <xs:element name="generator" minOccurs="0" type="GeneratorSpecificationType"/>
                </xs:sequence>
                <xs:attribute name="access" type="xs:string"/>
                <xs:attribute name="column" type="xs:string"/>
                <xs:attribute name="length" type="xs:int"/>
                <xs:attribute name="name" type="xs:string"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="type" type="xs:string"/>
                <xs:attribute name="unsaved-value" type="xs:string"/>
                <!-- any|none|null|undefined|0|-1|... -->
            </xs:extension>
        </xs:complexContent>

    </xs:complexType>
    <xs:complexType name="CompositeIdType">
        <xs:annotation>
            <xs:documentation>
                A composite key may be modelled by a java class with a property for each
                key column. The class must implement java.io.Serializable and reimplement equals()
                and hashCode().
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:choice maxOccurs="unbounded">
                        <xs:element name="key-property" type="CompositeKeyBasicAttributeType"/>
                        <xs:element name="key-many-to-one" type="CompositeKeyManyToOneType"/>
                    </xs:choice>
                    <xs:element name="generator" minOccurs="0" type="GeneratorSpecificationType"/>
                </xs:sequence>
                <xs:attribute name="access" type="xs:string"/>
                <xs:attribute name="class" type="ClassNameType"/>
                <xs:attribute name="mapped" default="false" type="xs:boolean"/>
                <xs:attribute name="name" type="xs:string"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="unsaved-value" default="undefined" type="UnsavedValueCompositeIdEnum"/>
            </xs:extension>
        </xs:complexContent>

    </xs:complexType>

    <xs:complexType name="BaseVersionAttributeType" abstract="true">
        <xs:annotation>
            <xs:documentation>
                Type definition that acts as a base for concrete definitions of mapped
                attributes that can function as the basis of optimistic locking.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:attribute name="access" type="xs:string"/>
                <xs:attribute name="column" type="xs:string"/>
                <xs:attribute name="generated" default="never" type="GenerationTimingVersionEnum"/>
                <xs:attribute name="name" use="required" type="xs:string"/>
                <xs:attribute name="node" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="VersionAttributeType">
        <xs:annotation>
            <xs:documentation>
                Optimistic locking attribute based on an incrementing value.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="BaseVersionAttributeType">
                <xs:sequence>
                    <xs:element name="column" minOccurs="0" maxOccurs="unbounded" type="ColumnType"/>
                </xs:sequence>
                <xs:attribute name="insert" type="xs:boolean"/>
                <xs:attribute name="type" default="integer" type="xs:string"/>
                <xs:attribute name="unsaved-value" default="undefined" type="UnsavedValueVersionEnum"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="TimestampAttributeType">
        <xs:annotation>
            <xs:documentation>
                Optimistic locking attribute based on a (last-updated) timestamp.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="BaseVersionAttributeType">
                <xs:attribute name="source" default="vm" type="TimestampSourceEnum"/>
                <xs:attribute name="unsaved-value" default="null" type="UnsavedValueTimestampEnum"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="natural-id-type">
        <xs:annotation>
            <xs:documentation>
                A natural-id element allows declaration of the unique business key
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:appinfo>
                        <jaxb:property name="attributes"/>
                    </xs:appinfo>
                </xs:annotation>
                <xs:element name="property" type="BasicAttributeType"/>
                <xs:element name="many-to-one" type="ManyToOneType"/>
                <xs:element name="component" type="CompositeAttributeType"/>
                <xs:element name="dynamic-component" type="dynamic-component-type"/>
                <xs:element name="any" type="AnyAssociationType"/>
            </xs:choice>
        </xs:sequence>
        <xs:attribute name="mutable" default="false" type="xs:boolean"/>
    </xs:complexType>



    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Collections -->

    <xs:complexType name="IdBagCollectionType">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="subselect" minOccurs="0" type="xs:string"/>
                    <xs:element name="cache" minOccurs="0" type="CacheType"/>
                    <xs:element name="synchronize" minOccurs="0" maxOccurs="unbounded" type="synchronize-type"/>
                    <!-- The comment element allows definition of a database table or column comment. -->
                    <xs:element name="comment" minOccurs="0" type="xs:string"/>
                    <xs:element name="collection-id" type="CollectionIdType" />
                    <xs:element name="key" type="key-type"/>
                    <xs:choice>
                        <xs:element name="element" type="BasicCollectionElementType"/>
                        <xs:element name="many-to-many" type="ManyToManyCollectionElementType"/>
                        <xs:element name="composite-element" type="CompositeCollectionElementType"/>
                        <xs:element name="many-to-any" type="ManyToAnyCollectionElementType"/>
                    </xs:choice>
                    <xs:element name="loader" minOccurs="0" type="loader-type"/>
                    <xs:group ref="CustomSqlDmlCollectionGroup"/>
                    <xs:element name="filter" minOccurs="0" maxOccurs="unbounded" type="filter-type"/>
                </xs:sequence>
                <xs:attributeGroup ref="table-information-group"/>
                <xs:attributeGroup ref="plural-basic-attribute-group"/>
                <xs:attribute name="embed-xml" type="xs:boolean"/>
                <xs:attribute name="fetch" type="FetchStyleWithSubselectEnum"/>
                <xs:attribute name="lazy" type="LazyWithExtraEnum"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="order-by" type="xs:string"/>
                <!-- default: none -->
                <xs:attribute name="outer-join" type="OuterJoinEnum"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="CollectionIdType">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="column" minOccurs="0" maxOccurs="unbounded" type="ColumnType"/>
                    <xs:element name="generator" type="GeneratorSpecificationType"/>
                </xs:sequence>
                <xs:attribute name="column" use="required" type="xs:string"/>
                <xs:attribute name="length" type="xs:int"/>
                <xs:attribute name="type" use="required" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="ArrayType">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="subselect" minOccurs="0" type="xs:string"/>
                    <xs:element name="cache" minOccurs="0" type="CacheType"/>
                    <xs:element name="synchronize" minOccurs="0" maxOccurs="unbounded" type="synchronize-type"/>
                    <!-- The comment element allows definition of a database table or column comment. -->
                    <xs:element name="comment" minOccurs="0" type="xs:string"/>
                    <xs:element name="key" type="key-type"/>
                    <xs:choice>
                        <xs:element name="index" type="index-type"/>
                        <xs:element name="list-index" type="ListIndexType"/>
                    </xs:choice>
                    <xs:group ref="CollectionElementOptionGroup"/>
                    <xs:element name="loader" minOccurs="0" type="loader-type"/>
                    <xs:group ref="CustomSqlDmlCollectionGroup"/>
                    <xs:element name="filter" minOccurs="0" maxOccurs="unbounded" type="filter-type"/>
                </xs:sequence>
                <xs:attributeGroup ref="table-information-group"/>
                <xs:attribute name="access" type="xs:string"/>
                <xs:attribute name="batch-size" default="-1" type="xs:int"/>
                <xs:attribute name="cascade" type="xs:string"/>
                <xs:attribute name="check" type="xs:string"/>
                <!-- default: none -->
                <xs:attribute name="collection-type" type="xs:string"/>
                <xs:attribute name="element-class" type="xs:string"/>
                <xs:attribute name="embed-xml" type="xs:boolean"/>
                <xs:attribute name="fetch" type="FetchStyleWithSubselectEnum"/>
                <xs:attribute name="lazy" type="LazyWithExtraEnum"/>
                <xs:attribute name="inverse" default="false" type="xs:boolean"/>
                <xs:attribute name="mutable" default="true" type="xs:boolean"/>
                <xs:attribute name="name" use="required" type="xs:string"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="optimistic-lock" default="true" type="xs:boolean"/>
                <!-- only supported for properties of a class (not component) -->
                <xs:attribute name="outer-join" type="OuterJoinEnum"/>
                <xs:attribute name="persister" type="ClassNameType"/>
                <xs:attribute name="where" type="xs:string"/>
                <!-- default: none -->
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="BagCollectionType">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="subselect" minOccurs="0" type="xs:string"/>
                    <xs:element name="cache" minOccurs="0" type="CacheType"/>
                    <xs:element name="synchronize" minOccurs="0" maxOccurs="unbounded" type="synchronize-type"/>
                    <!-- The comment element allows definition of a database table or column comment. -->
                    <xs:element name="comment" minOccurs="0" type="xs:string"/>
                    <xs:element name="key" type="key-type"/>
                    <xs:group ref="CollectionElementOptionGroup"/>
                    <xs:element name="loader" minOccurs="0" type="loader-type"/>
                    <xs:group ref="CustomSqlDmlCollectionGroup"/>
                    <xs:element name="filter" minOccurs="0" maxOccurs="unbounded" type="filter-type"/>
                </xs:sequence>
                <xs:attributeGroup ref="table-information-group"/>
                <xs:attributeGroup ref="plural-basic-attribute-group"/>
                <xs:attribute name="embed-xml" type="xs:boolean"/>
                <xs:attribute name="fetch" type="FetchStyleWithSubselectEnum"/>
                <xs:attribute name="lazy" type="LazyWithExtraEnum"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="order-by" type="xs:string"/>
                <!-- default: none -->
                <xs:attribute name="outer-join" type="OuterJoinEnum"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="ListType">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="subselect" minOccurs="0" type="xs:string"/>
                    <xs:element name="cache" minOccurs="0" type="CacheType"/>
                    <xs:element name="synchronize" minOccurs="0" maxOccurs="unbounded" type="synchronize-type"/>
                    <!-- The comment element allows definition of a database table or column comment. -->
                    <xs:element name="comment" minOccurs="0" type="xs:string"/>
                    <xs:element name="key" type="key-type"/>
                    <xs:choice>
                        <xs:element name="index" type="index-type"/>
                        <xs:element name="list-index" type="ListIndexType"/>
                    </xs:choice>
                    <xs:group ref="CollectionElementOptionGroup"/>
                    <xs:element name="loader" minOccurs="0" type="loader-type"/>
                    <xs:group ref="CustomSqlDmlCollectionGroup"/>
                    <xs:element name="filter" minOccurs="0" maxOccurs="unbounded" type="filter-type"/>
                </xs:sequence>
                <xs:attributeGroup ref="table-information-group"/>
                <xs:attributeGroup ref="plural-basic-attribute-group"/>
                <xs:attribute name="embed-xml" type="xs:boolean"/>
                <xs:attribute name="fetch" type="FetchStyleWithSubselectEnum"/>
                <xs:attribute name="lazy" type="LazyWithExtraEnum"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="outer-join" type="OuterJoinEnum"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="MapType">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="subselect" minOccurs="0" type="xs:string"/>
                    <xs:element name="cache" minOccurs="0" type="CacheType"/>
                    <xs:element name="synchronize" minOccurs="0" maxOccurs="unbounded" type="synchronize-type"/>
                    <!-- The comment element allows definition of a database table or column comment. -->
                    <xs:element name="comment" minOccurs="0" type="xs:string"/>
                    <xs:element name="key" type="key-type"/>
                    <xs:choice>
                        <xs:element name="map-key" type="MapKeyBasicType"/>
                        <xs:element name="composite-map-key" type="MapKeyCompositeType"/>
                        <xs:element name="map-key-many-to-many" type="MapKeyManyToManyType"/>
                        <xs:element name="index" type="index-type"/>
                        <xs:element name="composite-index" type="composite-index-type"/>
                        <xs:element name="index-many-to-many" type="index-many-to-many-type"/>
                        <xs:element name="index-many-to-any" type="index-many-to-any-type"/>
                    </xs:choice>
                    <xs:group ref="CollectionElementOptionGroup"/>
                    <xs:element name="loader" minOccurs="0" type="loader-type"/>
                    <xs:group ref="CustomSqlDmlCollectionGroup"/>
                    <xs:element name="filter" minOccurs="0" maxOccurs="unbounded" type="filter-type"/>
                </xs:sequence>
                <xs:attributeGroup ref="table-information-group"/>
                <xs:attributeGroup ref="plural-basic-attribute-group"/>
                <xs:attribute name="embed-xml" type="xs:boolean"/>
                <xs:attribute name="fetch" type="FetchStyleWithSubselectEnum"/>
                <xs:attribute name="lazy" type="LazyWithExtraEnum"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="order-by" type="xs:string"/>
                <!-- default: none -->
                <xs:attribute name="outer-join" type="OuterJoinEnum"/>
                <!-- unsorted|natural|"comparator class", default: unsorted -->
                <xs:attribute name="sort" default="unsorted" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="SetType">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="subselect" minOccurs="0" type="xs:string"/>
                    <xs:element name="cache" minOccurs="0" type="CacheType"/>
                    <xs:element name="synchronize" minOccurs="0" maxOccurs="unbounded" type="synchronize-type"/>
                    <!-- The comment element allows definition of a database table or column comment. -->
                    <xs:element name="comment" minOccurs="0" type="xs:string"/>
                    <xs:element name="key" type="key-type"/>
                    <xs:group ref="CollectionElementOptionGroup"/>
                    <xs:element name="loader" minOccurs="0" type="loader-type"/>
                    <xs:group ref="CustomSqlDmlCollectionGroup"/>
                    <xs:element name="filter" minOccurs="0" maxOccurs="unbounded" type="filter-type"/>
                </xs:sequence>
                <xs:attributeGroup ref="table-information-group"/>
                <xs:attributeGroup ref="plural-basic-attribute-group"/>
                <xs:attribute name="embed-xml" type="xs:boolean"/>
                <xs:attribute name="fetch" type="FetchStyleWithSubselectEnum"/>
                <xs:attribute name="lazy" type="LazyWithExtraEnum"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="order-by" type="xs:string"/>
                <!-- default: none -->
                <xs:attribute name="outer-join" type="OuterJoinEnum"/>
                <xs:attribute name="sort" default="unsorted" type="xs:string"/>
                <!-- unsorted|natural|"comparator class" -->
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="ListIndexType">
        <xs:sequence>
            <xs:element name="column" minOccurs="0" type="ColumnType"/>
        </xs:sequence>
        <xs:attribute name="base" default="0" type="xs:string"/>
        <xs:attribute name="column" type="xs:string"/>
    </xs:complexType>



    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Associations -->

    <xs:complexType name="OneToManyCollectionElementType">
        <xs:attribute name="class" type="ClassNameType"/>
        <xs:attribute name="embed-xml" type="xs:boolean"/>
        <xs:attribute name="entity-name" type="xs:string"/>
        <xs:attribute name="node" type="xs:string"/>
        <xs:attribute name="not-found" default="exception" type="NotFoundEnum"/>
    </xs:complexType>

    <xs:complexType name="OneToOneType">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="formula" minOccurs="0" maxOccurs="unbounded" type="xs:string"/>
                </xs:sequence>
                <xs:attribute name="access" type="xs:string"/>
                <xs:attribute name="cascade" type="xs:string"/>
                <xs:attribute name="class" type="ClassNameType"/>
                <xs:attribute name="constrained" default="false" type="xs:boolean"/>
                <xs:attribute name="embed-xml" type="xs:boolean"/>
                <xs:attribute name="entity-name" type="xs:string"/>
                <xs:attribute name="fetch" type="FetchStyleEnum"/>
                <xs:attribute name="foreign-key" type="xs:string"/>
                <xs:attribute name="formula" type="xs:string"/>
                <xs:attribute name="lazy" type="LazyWithNoProxyEnum"/>
                <xs:attribute name="name" use="required" type="xs:string"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="outer-join" type="OuterJoinEnum"/>
                <xs:attribute name="property-ref" type="xs:string"/>
                <xs:attribute name="on-delete" default="noaction" type="OnDeleteEnum"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="ManyToOneType">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:group ref="column-or-formula"/>
                    </xs:choice>
                </xs:sequence>
                <xs:attribute name="access" type="xs:string"/>
                <xs:attribute name="cascade" type="xs:string"/>
                <xs:attribute name="class" type="ClassNameType"/>
                <xs:attribute name="column" type="xs:string"/>
                <xs:attribute name="embed-xml" type="xs:boolean"/>
                <xs:attribute name="entity-name" type="xs:string"/>
                <xs:attribute name="fetch" type="FetchStyleEnum"/>
                <xs:attribute name="foreign-key" type="xs:string"/>
                <xs:attribute name="formula" type="xs:string"/>
                <xs:attribute name="index" type="xs:string"/>
                <xs:attribute name="insert" default="true" type="xs:boolean"/>
                <xs:attribute name="lazy" type="LazyWithNoProxyEnum"/>
                <xs:attribute name="name" use="required" type="xs:string"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="not-found" default="exception" type="NotFoundEnum"/>
                <xs:attribute name="not-null" type="xs:boolean"/>
                <xs:attribute name="optimistic-lock" default="true" type="xs:boolean"/>
                <!-- only supported for properties of a class (not component) -->
                <xs:attribute name="outer-join" type="OuterJoinEnum"/>
                <xs:attribute name="property-ref" type="xs:string"/>
                <xs:attribute name="unique" default="false" type="xs:boolean"/>
                <xs:attribute name="unique-key" type="xs:string"/>
                <xs:attribute name="update" default="true" type="xs:boolean"/>
                <xs:attribute name="on-delete" default="noaction" type="OnDeleteEnum"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="ManyToManyCollectionElementType">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:group ref="column-or-formula"/>
                    </xs:choice>
                    <xs:element name="filter" minOccurs="0" maxOccurs="unbounded" type="filter-type"/>
                </xs:sequence>
                <xs:attribute name="class" type="ClassNameType"/>
                <xs:attribute name="column" type="xs:string"/>
                <xs:attribute name="embed-xml" type="xs:boolean"/>
                <xs:attribute name="entity-name" type="xs:string"/>
                <xs:attribute name="fetch" type="FetchStyleEnum"/>
                <xs:attribute name="foreign-key" type="xs:string"/>
                <xs:attribute name="formula" type="xs:string"/>
                <xs:attribute name="lazy" type="LazyEnum"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="not-found" default="exception" type="NotFoundEnum"/>
                <xs:attribute name="order-by" type="xs:string"/>
                <xs:attribute name="outer-join" type="OuterJoinEnum"/>
                <xs:attribute name="property-ref" type="xs:string"/>
                <xs:attribute name="unique" default="false" type="xs:boolean"/>
                <xs:attribute name="where" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>


    <xs:complexType name="multi-tenancy-type">
        <xs:sequence>
            <xs:group minOccurs="0" ref="column-or-formula"/>
        </xs:sequence>
        <xs:attribute name="column" type="xs:string"/>
        <xs:attribute name="formula" type="xs:string"/>
        <xs:attribute name="shared" type="xs:boolean" default="true"/>
        <xs:attribute name="bind-as-param" type="xs:boolean" default="true"/>
    </xs:complexType>

    <xs:complexType name="EntityDiscriminatorType">
        <xs:annotation>
            <xs:documentation>
                Polymorphic data requires a column holding a class discriminator value. This
                value is not directly exposed to the application.
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:group minOccurs="0" ref="column-or-formula"/>
        </xs:sequence>
        <xs:attribute name="column" type="xs:string"/>
        <!-- default: "class"|none -->
        <xs:attribute name="force" default="false" type="xs:boolean"/>
        <xs:attribute name="formula" type="xs:string"/>
        <xs:attribute name="insert" default="true" type="xs:boolean"/>
        <xs:attribute name="length" type="xs:int"/>
        <xs:attribute name="not-null" default="true" type="xs:boolean"/>
        <xs:attribute name="type" default="string" type="xs:string"/>
    </xs:complexType>




    <xs:complexType name="AnyAssociationType">
        <xs:annotation>
            <xs:documentation>
                A discriminated association where the discriminator is part of the
                association, not the associated entity (compared to discriminator subclass)
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="meta-value" minOccurs="0" maxOccurs="unbounded" type="AnyValueMappingType"/>
                    <xs:element name="column" maxOccurs="unbounded" type="ColumnType"/>
                </xs:sequence>
                <xs:attribute name="access" type="xs:string"/>
                <xs:attribute name="cascade" type="xs:string"/>
                <xs:attribute name="id-type" use="required" type="xs:string"/>
                <xs:attribute name="index" type="xs:string"/>
                <!-- include the columns spanned by this association in an index -->
                <xs:attribute name="insert" default="true" type="xs:boolean"/>
                <xs:attribute name="lazy" default="false" type="xs:boolean"/>
                <xs:attribute name="meta-type" type="xs:string"/>
                <!--- default: Hibernate.STRING -->
                <xs:attribute name="name" use="required" type="xs:string"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="optimistic-lock" default="true" type="xs:boolean"/>
                <!-- only supported for properties of a class (not component) -->
                <xs:attribute name="update" default="true" type="xs:boolean"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="AnyValueMappingType">
        <xs:annotation>
            <xs:documentation>
                Defines the mapping of a discriminator value to a concrete entity in an any or
                any-to-many mapping.
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="class" use="required" type="xs:string"/>
        <xs:attribute name="value" use="required" type="xs:string"/>
    </xs:complexType>


    <!-- The cache element enables caching of an entity class. -->
    <xs:complexType name="CacheType">
        <xs:attribute name="include" default="all" type="CacheInclusionEnum"/>
        <xs:attribute name="region" type="xs:string"/>
        <!-- default: class or collection role name -->
        <xs:attribute name="usage" use="required" type="CacheUsageEnum"/>
    </xs:complexType>

    <xs:complexType name="NaturalIdCacheType">
        <xs:attribute name="region" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="ColumnType">
        <xs:annotation>
            <xs:documentation>
                The column element is an alternative to column attributes and required for
                mapping associations to classes with composite ids.
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:annotation>
                <xs:documentation>
                    The comment element allows definition of a database table or column comment.
                </xs:documentation>
            </xs:annotation>
            <xs:element name="comment" minOccurs="0" type="xs:string"/>
        </xs:sequence>
        <xs:attribute name="check" type="xs:string"/>
        <!-- default: no check constraint -->
        <xs:attribute name="default" type="xs:string"/>
        <!-- default: no default value -->
        <xs:attribute name="index" type="xs:string"/>
        <xs:attribute name="length" type="xs:int"/>
        <!-- default: 255 -->
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="not-null" type="xs:boolean"/>
        <!-- default: false (except for id properties) -->
        <xs:attribute name="precision" type="xs:int"/>
        <xs:attribute name="read" type="xs:string"/>
        <!-- default: column name -->
        <xs:attribute name="scale" type="xs:int"/>
        <xs:attribute name="sql-type" type="xs:string"/>
        <!-- override default column type for hibernate type -->
        <xs:attribute name="unique" type="xs:boolean"/>
        <!-- default: false (except for id properties) -->
        <xs:attribute name="unique-key" type="xs:string"/>
        <!-- default: no unique key -->
        <xs:attribute name="write" type="xs:string"/>
        <!-- default: parameter placeholder ('?') -->
    </xs:complexType>

    <xs:complexType name="CompositeAttributeType">
        <xs:annotation>
            <xs:documentation>
                A component is a user-defined class, persisted along with its containing entity
                to the table of the entity class. JavaBeans style properties of the component are
                mapped to columns of the table of the containing entity. A null component reference
                is mapped to null values in all columns and vice versa. Components do not support
                shared reference semantics.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="tuplizer" minOccurs="0" maxOccurs="unbounded" type="tuplizer-type"/>
                    <xs:element name="parent" minOccurs="0" type="parent-type"/>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:annotation>
                            <xs:appinfo>
                                <jaxb:property name="attributes" />
                                <!--<simplify:as-element-property/>-->
                            </xs:appinfo>
                        </xs:annotation>
                        <xs:group ref="SingularAttributeGroup"/>
                    </xs:choice>
                </xs:sequence>
                <xs:attribute name="access" type="xs:string"/>
                <xs:attribute name="class" type="ClassNameType"/>
                <xs:attribute name="insert" default="true" type="xs:boolean"/>
                <xs:attribute name="lazy" default="false" type="xs:boolean"/>
                <xs:attribute name="name" use="required" type="xs:string"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="optimistic-lock" default="true" type="xs:boolean"/>
                <xs:attribute name="unique" default="false" type="xs:boolean"/>
                <xs:attribute name="update" default="true" type="xs:boolean"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="CompositeCollectionElementType">
        <xs:annotation>
            <xs:documentation>
                A composite element allows a collection to hold instances of an arbitrary
                class, without the requirement of joining to an entity table. Composite elements
                have component semantics - no shared references and ad hoc null value semantics.
                Composite elements may not hold nested collections.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="parent" minOccurs="0" type="parent-type"/>
                    <xs:element name="tuplizer" minOccurs="0" maxOccurs="unbounded" type="tuplizer-type"/>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:annotation>
                            <xs:appinfo>
                                <jaxb:property name="attributes"/>
                            </xs:appinfo>
                        </xs:annotation>
                        <xs:element name="property" type="BasicAttributeType"/>
                        <xs:element name="many-to-one" type="ManyToOneType"/>
                        <xs:element name="any" type="AnyAssociationType"/>
                        <xs:element name="nested-composite-element" type="nested-composite-element-type"/>
                    </xs:choice>
                </xs:sequence>
                <xs:attribute name="class" use="required" type="ClassNameType"/>
                <xs:attribute name="node" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="dynamic-component-type">
        <xs:annotation>
            <xs:documentation>
                A dynamic-component maps columns of the database entity to a java.util.Map
                at the Java level
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:appinfo>
                        <jaxb:property name="attributes" />
                        <!--<simplify:as-element-property/>-->
                    </xs:appinfo>
                </xs:annotation>
                <xs:group ref="SingularAttributeGroup"/>
            </xs:choice>
        </xs:sequence>
        <xs:attribute name="access" type="xs:string"/>
        <xs:attribute name="insert" default="true" type="xs:boolean"/>
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="node" type="xs:string"/>
        <xs:attribute name="optimistic-lock" default="true" type="xs:boolean"/>
        <xs:attribute name="unique" default="false" type="xs:boolean"/>
        <xs:attribute name="update" default="true" type="xs:boolean"/>
    </xs:complexType>

    <xs:complexType name="BasicCollectionElementType">
        <xs:annotation>
            <xs:documentation>
                Declares the element type of a collection where the element is of basic type
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:group ref="column-or-formula"/>
            </xs:choice>
            <xs:element name="type" minOccurs="0" type="TypeSpecificationType"/>
        </xs:sequence>
        <xs:attribute name="column" type="xs:string"/>
        <xs:attribute name="formula" type="xs:string"/>
        <xs:attribute name="length" type="xs:int"/>
        <xs:attribute name="node" type="xs:string"/>
        <xs:attribute name="not-null" default="false" type="xs:boolean"/>
        <xs:attribute name="precision" type="xs:int"/>
        <xs:attribute name="scale" type="xs:int"/>
        <xs:attribute name="type" type="xs:string"/>
        <xs:attribute name="unique" default="false" type="xs:boolean"/>
    </xs:complexType>

    <xs:complexType name="filter-type" mixed="true">
        <xs:annotation>
            <xs:documentation>
                FILTER element; used to apply a filter.
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="aliases" type="filter-alias-mapping-type" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="condition" type="xs:string"/>
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="autoAliasInjection" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="filter-alias-mapping-type">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="alias" type="xs:string" use="required"/>
                <xs:attribute name="table" type="xs:string"/>
                <xs:attribute name="entity" type="xs:string"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:complexType name="GeneratorSpecificationType">
        <xs:annotation>
            <xs:documentation>
                Generators generate unique identifiers. The class attribute specifies a Java
                class implementing an id generation algorithm.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="ConfigParameterContainer">
                <xs:attribute name="class" use="required" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>


    <xs:complexType name="index-type">
        <xs:annotation>
            <xs:documentation>
                Describes the index of an indexed collection.  Indexed collection means either
                a java.util.List, a persistent array or a java.util.Map.

                For a List or array, this describes the list/array index value.  Should prefer
                to use 'list-index' instead.

                For a Map, this describes the Map key value.  Should prefer to use 'map-key' instead
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="column" minOccurs="0" maxOccurs="unbounded" type="ColumnType"/>
        </xs:sequence>
        <xs:attribute name="column" type="xs:string" />
        <xs:attribute name="length" type="xs:int"/>
        <xs:attribute name="type" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="SecondaryTableType">
        <xs:annotation>
            <xs:documentation>
                A join allows some properties of a class to be persisted to a second table
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="subselect" minOccurs="0" type="xs:string"/>
            <!-- The comment element allows definition of a database table or column comment. -->
            <xs:element name="comment" minOccurs="0" type="xs:string"/>
            <xs:element name="key" type="key-type"/>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:appinfo>
                        <jaxb:property name="attributes"/>
                    </xs:appinfo>
                </xs:annotation>
                <xs:element name="property" type="BasicAttributeType"/>
                <xs:element name="many-to-one" type="ManyToOneType"/>
                <xs:element name="component" type="CompositeAttributeType"/>
                <xs:element name="dynamic-component" type="dynamic-component-type"/>
                <xs:element name="any" type="AnyAssociationType"/>
            </xs:choice>
            <xs:group ref="CustomSqlDmlGroup"/>
        </xs:sequence>
        <xs:attributeGroup ref="table-information-group"/>
        <xs:attribute name="fetch" default="join" type="FetchStyleEnum"/>
        <xs:attribute name="inverse" default="false" type="xs:boolean"/>
        <xs:attribute name="optional" default="false" type="xs:boolean"/>
    </xs:complexType>


    <xs:complexType name="key-type">
        <xs:annotation>
            <xs:documentation>
                Declares the column name of a foreign key.
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="column" minOccurs="0" maxOccurs="unbounded" type="ColumnType"/>
        </xs:sequence>
        <xs:attribute name="column" type="xs:string"/>
        <xs:attribute name="foreign-key" type="xs:string"/>
        <xs:attribute name="not-null" type="xs:boolean"/>
        <xs:attribute name="on-delete" default="noaction" type="OnDeleteEnum"/>
        <xs:attribute name="property-ref" type="xs:string"/>
        <xs:attribute name="unique" type="xs:boolean"/>
        <xs:attribute name="update" type="xs:boolean"/>
    </xs:complexType>

    <xs:complexType name="CompositeKeyManyToOneType">
        <xs:annotation>
            <xs:documentation>
                A many-to-one association embedded in a composite identifier or map index
                (always not-null, never cascade).
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="column" minOccurs="0" maxOccurs="unbounded" type="ColumnType"/>
                </xs:sequence>
                <xs:attribute name="access" type="xs:string"/>
                <xs:attribute name="class" type="ClassNameType"/>
                <xs:attribute name="column" type="xs:string"/>
                <xs:attribute name="entity-name" type="xs:string"/>
                <xs:attribute name="foreign-key" type="xs:string"/>
                <xs:attribute name="lazy" type="LazyEnum"/>
                <xs:attribute name="name" use="required" type="xs:string"/>
                <xs:attribute name="on-delete" default="noaction" type="OnDeleteEnum"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="CompositeKeyBasicAttributeType">
        <xs:annotation>
            <xs:documentation>
                A property embedded in a composite identifier or map index (always not-null).
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="column" minOccurs="0" maxOccurs="unbounded" type="ColumnType"/>
                    <xs:element name="type" minOccurs="0" type="TypeSpecificationType"/>
                </xs:sequence>
                <xs:attribute name="access" type="xs:string"/>
                <xs:attribute name="column" type="xs:string"/>
                <xs:attribute name="length" type="xs:int"/>
                <xs:attribute name="name" use="required" type="xs:string"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="type" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>


    <xs:complexType name="loader-type">
        <xs:annotation>
            <xs:documentation>
                The loader element allows specification of a named query to be used for fetching
                an entity or collection
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="query-ref" use="required" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="ManyToAnyCollectionElementType">
        <xs:annotation>
            <xs:documentation>
                A "many to any" defines a polymorphic association to any table
                with the given identifier type. The first listed column is a VARCHAR column
                holding the name of the class (for that row).
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="meta-value" minOccurs="0" maxOccurs="unbounded" type="AnyValueMappingType"/>
            <xs:element name="column" minOccurs="2" maxOccurs="unbounded" type="ColumnType"/>
        </xs:sequence>
        <xs:attribute name="id-type" use="required" type="xs:string"/>
        <xs:attribute name="meta-type" type="xs:string"/>
        <!--- default: Hibernate.CLASS -->
    </xs:complexType>


    <xs:complexType name="MapKeyBasicType">
        <xs:annotation>
            <xs:documentation>
                Describes the key of a java.util.Map where the key is a basic (JPA term) type
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:group ref="column-or-formula"/>
            </xs:choice>
            <xs:element name="type" minOccurs="0" type="TypeSpecificationType"/>
        </xs:sequence>
        <xs:attribute name="column" type="xs:string"/>
        <xs:attribute name="formula" type="xs:string"/>
        <xs:attribute name="length" type="xs:int"/>
        <xs:attribute name="node" type="xs:string"/>
        <xs:attribute name="type" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="MapKeyCompositeType">
        <xs:annotation>
            <xs:documentation>
                Describes the key of a java.util.Map where the key is a composite type
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:choice maxOccurs="unbounded">
                <xs:annotation>
                    <xs:appinfo>
                        <jaxb:property name="attributes"/>
                    </xs:appinfo>
                </xs:annotation>
                <xs:element name="key-property" type="CompositeKeyBasicAttributeType"/>
                <xs:element name="key-many-to-one" type="CompositeKeyManyToOneType"/>
            </xs:choice>
        </xs:sequence>
        <xs:attribute name="class" use="required" type="ClassNameType"/>
    </xs:complexType>

    <xs:complexType name="MapKeyManyToManyType">
        <xs:annotation>
            <xs:documentation>
                Describes the key of a java.util.Map where the key is an association (FK)
            </xs:documentation>
        </xs:annotation>
        <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:group ref="column-or-formula"/>
        </xs:sequence>
        <xs:attribute name="class" type="ClassNameType"/>
        <xs:attribute name="column" type="xs:string"/>
        <xs:attribute name="entity-name" type="xs:string"/>
        <xs:attribute name="foreign-key" type="xs:string"/>
        <xs:attribute name="formula" type="xs:string"/>
    </xs:complexType>
    <xs:complexType name="composite-index-type">
        <xs:annotation>
            <xs:documentation>
                Describes the key of a java.util.Map which is a composite.  Should prefer
                'composite-map-key' instead
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:choice maxOccurs="unbounded">
                <xs:annotation>
                    <xs:appinfo>
                        <jaxb:property name="attributes"/>
                    </xs:appinfo>
                </xs:annotation>
                <xs:element name="key-property" type="CompositeKeyBasicAttributeType"/>
                <xs:element name="key-many-to-one" type="CompositeKeyManyToOneType"/>
            </xs:choice>
        </xs:sequence>
        <xs:attribute name="class" use="required" type="ClassNameType"/>
    </xs:complexType>
    <xs:complexType name="index-many-to-many-type">
        <xs:annotation>
            <xs:documentation>
                Describes the key of a java.util.Map which is an FK-association.  Should prefer
                'map-key-many-to-many' instead
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="column" minOccurs="0" maxOccurs="unbounded" type="ColumnType"/>
        </xs:sequence>
        <xs:attribute name="class" use="required" type="ClassNameType"/>
        <xs:attribute name="column" type="xs:string"/>
        <xs:attribute name="entity-name" type="xs:string"/>
        <xs:attribute name="foreign-key" type="xs:string"/>
    </xs:complexType>
    <xs:complexType name="index-many-to-any-type">
        <xs:sequence>
            <xs:element name="column" minOccurs="2" maxOccurs="unbounded" type="ColumnType"/>
        </xs:sequence>
        <xs:attribute name="id-type" use="required" type="xs:string"/>
        <xs:attribute name="meta-type" type="xs:string"/>
        <!--- default: Hibernate.CLASS -->
    </xs:complexType>

    <xs:complexType name="nested-composite-element-type">
        <xs:sequence>
            <xs:element name="parent" minOccurs="0" type="parent-type"/>
            <xs:element name="tuplizer" minOccurs="0" maxOccurs="unbounded" type="tuplizer-type"/>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:appinfo>
                        <jaxb:property name="attributes"/>
                    </xs:appinfo>
                </xs:annotation>
                <xs:element name="property" type="BasicAttributeType"/>
                <xs:element name="many-to-one" type="ManyToOneType"/>
                <xs:element name="any" type="AnyAssociationType"/>
                <xs:element name="nested-composite-element" type="nested-composite-element-type"/>
            </xs:choice>
        </xs:sequence>
        <xs:attribute name="access" type="xs:string"/>
        <xs:attribute name="class" use="required" type="ClassNameType"/>
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="node" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="parent-type">
        <xs:annotation>
            <xs:documentation>
                The parent element maps a property of the component class as a pointer back to
                the owning entity.
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="name" use="required" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="PrimitiveArrayType">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:element name="subselect" minOccurs="0" type="xs:string"/>
                    <xs:element name="cache" minOccurs="0" type="CacheType"/>
                    <xs:element name="synchronize" minOccurs="0" maxOccurs="unbounded" type="synchronize-type"/>
                    <!-- The comment element allows definition of a database table or column comment. -->
                    <xs:element name="comment" minOccurs="0" type="xs:string"/>
                    <xs:element name="key" type="key-type"/>
                    <xs:choice>
                        <xs:element name="index" type="index-type"/>
                        <xs:element name="list-index" type="ListIndexType"/>
                    </xs:choice>
                    <xs:element name="element" type="BasicCollectionElementType"/>
                    <xs:element name="loader" minOccurs="0" type="loader-type"/>
                    <xs:group ref="CustomSqlDmlCollectionGroup"/>
                </xs:sequence>
                <xs:attributeGroup ref="table-information-group"/>
                <xs:attribute name="access" type="xs:string"/>
                <xs:attribute name="batch-size" default="-1" type="xs:int"/>
                <xs:attribute name="check" type="xs:string"/>
                <!-- default: none -->
                <xs:attribute name="collection-type" type="xs:string"/>
                <xs:attribute name="embed-xml" type="xs:boolean"/>
                <xs:attribute name="fetch" type="FetchStyleWithSubselectEnum"/>
                <xs:attribute name="mutable" default="true" type="xs:boolean"/>
                <xs:attribute name="name" use="required" type="xs:string"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="optimistic-lock" default="true" type="xs:boolean"/>
                <!-- only supported for properties of a class (not component) -->
                <xs:attribute name="outer-join" type="OuterJoinEnum"/>
                <xs:attribute name="persister" type="xs:string"/>
                <xs:attribute name="where" type="xs:string"/>
                <!-- default: none -->
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>

    <xs:complexType name="properties-type">
        <xs:annotation>
            <xs:documentation>
                properties declares that the contained properties form an alternate key. The name
                attribute allows an alternate key to be used as the target of a property-ref.
            </xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:annotation>
                    <xs:appinfo>
                        <jaxb:property name="attributes"/>
                        <!--<simplify:as-element-property/>-->
                    </xs:appinfo>
                </xs:annotation>
                <xs:element name="property" type="BasicAttributeType"/>
                <xs:element name="many-to-one" type="ManyToOneType"/>
                <xs:element name="component" type="CompositeAttributeType"/>
                <xs:element name="dynamic-component" type="dynamic-component-type"/>
            </xs:choice>
        </xs:sequence>
        <xs:attribute name="insert" default="true" type="xs:boolean"/>
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="node" type="xs:string"/>
        <xs:attribute name="optimistic-lock" default="true" type="xs:boolean"/>
        <xs:attribute name="unique" default="false" type="xs:boolean"/>
        <xs:attribute name="update" default="true" type="xs:boolean"/>
    </xs:complexType>

    <xs:complexType name="BasicAttributeType">
        <xs:complexContent>
            <xs:extension base="ToolingHintContainer">
                <xs:sequence>
                    <xs:choice minOccurs="0" maxOccurs="unbounded">
                        <xs:group ref="column-or-formula"/>
                    </xs:choice>
                    <xs:element name="type" minOccurs="0" type="TypeSpecificationType"/>
                </xs:sequence>
                <xs:attribute name="access" type="xs:string"/>
                <xs:attribute name="column" type="xs:string"/>
                <xs:attribute name="formula" type="xs:string"/>
                <xs:attribute name="generated" default="never" type="GenerationTimingEnum"/>
                <xs:attribute name="index" type="xs:string"/>
                <!-- include the columns spanned by this property in an index -->
                <xs:attribute name="insert" type="xs:boolean"/>
                <xs:attribute name="lazy" default="false" type="xs:boolean"/>
                <xs:attribute name="length" type="xs:int"/>
                <xs:attribute name="name" use="required" type="xs:string"/>
                <xs:attribute name="node" type="xs:string"/>
                <xs:attribute name="not-null" type="xs:boolean"/>
                <xs:attribute name="optimistic-lock" default="true" type="xs:boolean"/>
                <!-- only supported for properties of a class (not component) -->
                <xs:attribute name="precision" type="xs:string"/>
                <xs:attribute name="scale" type="xs:string"/>
                <xs:attribute name="type" type="xs:string"/>
                <xs:attribute name="unique" default="false" type="xs:boolean"/>
                <xs:attribute name="unique-key" type="xs:string"/>
                <xs:attribute name="update" type="xs:boolean"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>











    <xs:complexType name="synchronize-type">
        <xs:attribute name="table" use="required" type="xs:string"/>
    </xs:complexType>

    <xs:complexType name="tuplizer-type">
        <xs:annotation>
            <xs:documentation>
                TUPLIZER element; defines tuplizer to use for a component/entity for a given entity-mode
            </xs:documentation>
        </xs:annotation>
        <xs:attribute name="class" use="required" type="ClassNameType"/>
        <!-- the tuplizer class to use -->
        <xs:attribute name="entity-mode" type="EntityModeEnum"/>
    </xs:complexType>

    <xs:complexType name="TypeSpecificationType">
        <xs:annotation>
            <xs:documentation>
                Declares the type of the containing property (overrides an eventually existing type
                attribute of the property). May contain param elements to customize a ParametrizableType.
            </xs:documentation>
        </xs:annotation>
        <xs:complexContent>
            <xs:extension base="ConfigParameterContainer">
                <xs:attribute name="name" use="required" type="xs:string"/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>


    <xs:complexType name="ConfigParameterContainer" abstract="true">
        <xs:sequence>
            <xs:element name="param" minOccurs="0" maxOccurs="unbounded" type="ConfigParameterType"/>
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="ConfigParameterType" mixed="true">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="name" use="required" type="xs:string"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>


    <xs:group name="CollectionElementOptionGroup">
        <xs:choice>
            <xs:element name="element" type="BasicCollectionElementType"/>
            <xs:element name="one-to-many" type="OneToManyCollectionElementType"/>
            <xs:element name="many-to-many" type="ManyToManyCollectionElementType"/>
            <xs:element name="composite-element" type="CompositeCollectionElementType"/>
            <xs:element name="many-to-any" type="ManyToAnyCollectionElementType"/>
        </xs:choice>
    </xs:group>
    <xs:group name="column-or-formula">
        <xs:choice>
            <xs:element name="column" type="ColumnType"/>
            <xs:element name="formula" type="xs:string"/>
        </xs:choice>
    </xs:group>
    <xs:group name="SingularAttributeGroup">
        <xs:choice>
            <xs:element name="property" type="BasicAttributeType"/>
            <xs:element name="many-to-one" type="ManyToOneType"/>
            <xs:element name="one-to-one" type="OneToOneType"/>
            <xs:element name="component" type="CompositeAttributeType"/>
            <xs:element name="dynamic-component" type="dynamic-component-type"/>
            <xs:element name="properties" type="properties-type"/>
            <xs:element name="any" type="AnyAssociationType"/>
            <xs:element name="map" type="MapType"/>
            <xs:element name="set" type="SetType"/>
            <xs:element name="list" type="ListType"/>
            <xs:element name="bag" type="BagCollectionType"/>
            <xs:element name="array" type="ArrayType"/>
            <xs:element name="primitive-array" type="PrimitiveArrayType"/>
        </xs:choice>
    </xs:group>






    <xs:group name="CustomSqlDmlGroup">
        <xs:sequence>
            <xs:element name="sql-insert" minOccurs="0" type="CustomSqlDmlType"/>
            <xs:element name="sql-update" minOccurs="0" type="CustomSqlDmlType"/>
            <xs:element name="sql-delete" minOccurs="0" type="CustomSqlDmlType"/>
        </xs:sequence>
    </xs:group>

    <xs:group name="CustomSqlDmlCollectionGroup">
        <xs:sequence>
            <xs:element name="sql-insert" minOccurs="0" type="CustomSqlDmlType"/>
            <xs:element name="sql-update" minOccurs="0" type="CustomSqlDmlType"/>
            <xs:element name="sql-delete" minOccurs="0" type="CustomSqlDmlType"/>
            <xs:element name="sql-delete-all" minOccurs="0" type="CustomSqlDmlType"/>
        </xs:sequence>
    </xs:group>

    <xs:complexType name="CustomSqlDmlType" mixed="true">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="callable" default="false" type="xs:boolean"/>
                <xs:attribute name="check" type="ResultCheckStyleEnum"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>


    <xs:attributeGroup name="plural-basic-attribute-group">
        <xs:attribute name="name" use="required" type="xs:string"/>
        <xs:attribute name="access" type="xs:string"/>
        <xs:attribute name="check" type="xs:string"/>
        <!-- default: none -->
        <xs:attribute name="where" type="xs:string"/>
        <!-- default: none -->
        <xs:attribute name="cascade" type="xs:string"/>
        <xs:attribute name="batch-size" default="-1" type="xs:int"/>
        <xs:attribute name="inverse" default="false" type="xs:boolean"/>
        <xs:attribute name="mutable" default="true" type="xs:boolean"/>
        <xs:attribute name="optimistic-lock" default="true" type="xs:boolean"/>
        <!-- only supported for properties of a class (not component) -->
        <xs:attribute name="collection-type" type="xs:string"/>
        <xs:attribute name="persister" type="ClassNameType"/>
    </xs:attributeGroup>
    <xs:attributeGroup name="table-information-group">
        <xs:attribute name="schema" type="xs:string"/>
        <xs:attribute name="catalog" type="xs:string"/>
        <xs:attribute name="table" type="xs:string"/>
        <!-- default: unqualified class name -->
        <xs:attribute name="subselect" type="xs:string"/>
    </xs:attributeGroup>



    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Enums -->
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

    <xs:simpleType name="CacheInclusionEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="all"/>
            <xs:enumeration value="non-lazy"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="CacheModeEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="get"/>
            <xs:enumeration value="ignore"/>
            <xs:enumeration value="normal"/>
            <xs:enumeration value="put"/>
            <xs:enumeration value="refresh"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="CacheUsageEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="nonstrict-read-write"/>
            <xs:enumeration value="read-only"/>
            <xs:enumeration value="read-write"/>
            <xs:enumeration value="transactional"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="ResultCheckStyleEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="none"/>
            <xs:enumeration value="param"/>
            <xs:enumeration value="rowcount"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="EntityModeEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="dynamic-map"/>
            <xs:enumeration value="pojo"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="FetchStyleEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="join"/>
            <xs:enumeration value="select"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="FetchStyleWithSubselectEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="join"/>
            <xs:enumeration value="select"/>
            <xs:enumeration value="subselect"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="FlushModeEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="always"/>
            <xs:enumeration value="auto"/>
            <xs:enumeration value="never"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="GenerationTimingEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="always"/>
            <xs:enumeration value="insert"/>
            <xs:enumeration value="never"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="GenerationTimingVersionEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="always"/>
            <xs:enumeration value="never"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="LazyEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="false"/>
            <xs:enumeration value="proxy"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="LazyWithExtraEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="extra"/>
            <xs:enumeration value="false"/>
            <xs:enumeration value="true"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="LazyWithNoProxyEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="false"/>
            <xs:enumeration value="no-proxy"/>
            <xs:enumeration value="proxy"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="LockModeEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="none"/>
            <xs:enumeration value="read"/>
            <xs:enumeration value="upgrade"/>
            <xs:enumeration value="upgrade-nowait"/>
            <xs:enumeration value="upgrade-skiplocked"/>
            <xs:enumeration value="write"/>
            <xs:enumeration value="force"/>
            <xs:enumeration value="optimistic"/>
            <xs:enumeration value="optimistic_force_increment"/>
            <xs:enumeration value="pessimistic_read"/>
            <xs:enumeration value="pessimistic_write"/>
            <xs:enumeration value="pessimistic_force_increment"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="NotFoundEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="exception"/>
            <xs:enumeration value="ignore"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="OuterJoinEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="auto"/>
            <xs:enumeration value="false"/>
            <xs:enumeration value="true"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="OnDeleteEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="cascade"/>
            <xs:enumeration value="noaction"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="OptimisticLockStyleEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="all"/>
            <xs:enumeration value="dirty"/>
            <xs:enumeration value="none"/>
            <xs:enumeration value="version"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="PolymorphismEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="explicit"/>
            <xs:enumeration value="implicit"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="TimestampSourceEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="db"/>
            <xs:enumeration value="vm"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="UnsavedValueCompositeIdEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="any"/>
            <xs:enumeration value="none"/>
            <xs:enumeration value="undefined"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="UnsavedValueTimestampEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="null"/>
            <xs:enumeration value="undefined"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="UnsavedValueVersionEnum">
        <xs:restriction base="xs:token">
            <xs:enumeration value="negative"/>
            <xs:enumeration value="null"/>
            <xs:enumeration value="undefined"/>
        </xs:restriction>
    </xs:simpleType>



    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
    <!-- Support types -->
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

    <xs:simpleType name="ClassNameType">
        <xs:annotation>
            <xs:documentation>
                Define a class name type which can be used in the attribute value which requires a class name,
                either qualified or not, time to do the validation.
            </xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
            <xs:pattern value="([a-zA-Z_$][a-zA-Z\d_$]*\.)*[a-zA-Z_$][a-zA-Z\d_$]*"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
