Skip to content

Commit

Permalink
Align XSD with JPA 3.2 proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
sebersole committed Oct 28, 2023
1 parent 5cbd47b commit e1d1ae7
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.boot.jaxb.mapping.spi;

/**
* @author Steve Ebersole
*/
public interface JaxbCheckConstraint {
String getName();
String getConstraint();
String getOptions();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* SPDX-License-Identifier: Apache-2.0
* Copyright: Red Hat Inc. and Hibernate Authors
*/
package org.hibernate.boot.jaxb.mapping.spi;

/**
* @author Steve Ebersole
*/
public interface JaxbTableMapping extends JaxbSchemaAware {
JaxbCheckConstraint getCheck();
String getComment();
String getOptions();

// todo : see what JPA 3.2 decides about some of these XSD decisions
// - https://github.com/jakartaee/persistence/pull/541

String getCommentAttribute();
String getOptionsAttribute();
}
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="catalog" type="xsd:string"/>
<xsd:attribute name="schema" type="xsd:string"/>
<xsd:attribute name="comment" type="xsd:string"/>
<xsd:attribute name="options" type="xsd:string"/>
</xsd:complexType>

<!-- **************************************************** -->
Expand Down Expand Up @@ -1265,14 +1267,20 @@
See `@jakarta.persistence.JoinColumn`
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="foreign-key" type="orm:foreign-key" minOccurs="0"/>
<xsd:element name="check-constraint" type="orm:check-constraint" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="referenced-column-name" type="xsd:string"/>
<xsd:attribute name="unique" type="xsd:boolean"/>
<xsd:attribute name="nullable" type="xsd:boolean"/>
<xsd:attribute name="insertable" type="xsd:boolean"/>
<xsd:attribute name="updatable" type="xsd:boolean"/>
<xsd:attribute name="column-definition" type="xsd:string"/>
<xsd:attribute name="options" type="xsd:string"/>
<xsd:attribute name="table" type="xsd:string"/>
<xsd:attribute name="comment" type="xsd:string"/>
</xsd:complexType>

<!-- **************************************************** -->
Expand All @@ -1299,6 +1307,8 @@
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="catalog" type="xsd:string"/>
<xsd:attribute name="schema" type="xsd:string"/>
<xsd:attribute name="comment" type="xsd:string"/>
<xsd:attribute name="options" type="xsd:string"/>
</xsd:complexType>

<!-- **************************************************** -->
Expand Down Expand Up @@ -1481,6 +1491,9 @@
See `@jakarta.persistence.MapKeyJoinColumn`
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="foreign-key" type="orm:foreign-key" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="referenced-column-name" type="xsd:string"/>
<xsd:attribute name="unique" type="xsd:boolean"/>
Expand Down Expand Up @@ -2178,7 +2191,7 @@
<xsd:sequence>
<xsd:element name="description" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="sequence-name" type="xsd:string"/>
<xsd:attribute name="catalog" type="xsd:string"/>
<xsd:attribute name="schema" type="xsd:string"/>
Expand Down Expand Up @@ -2239,6 +2252,8 @@
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="catalog" type="xsd:string"/>
<xsd:attribute name="schema" type="xsd:string"/>
<xsd:attribute name="comment" type="xsd:string"/>
<xsd:attribute name="options" type="xsd:string"/>
</xsd:complexType>

<xsd:group name="hbm-common-table-extensions">
Expand All @@ -2249,8 +2264,9 @@
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="check" type="orm:check-constraint" minOccurs="0" />
<xsd:element name="options" type="xsd:string" minOccurs="0" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" />
<xsd:element name="check" type="xsd:string" minOccurs="0" />
</xsd:sequence>
</xsd:group>

Expand Down Expand Up @@ -2287,6 +2303,8 @@
<xsd:attribute name="schema" type="xsd:string"/>
<!-- hbm: Hibernate allows controlling whether the joined rows for this secondary table are required (inner join) or optional (outer join)-->
<xsd:attribute name="optional" type="xsd:boolean"/>
<xsd:attribute name="comment" type="xsd:string"/>
<xsd:attribute name="options" type="xsd:string"/>
</xsd:complexType>


Expand Down Expand Up @@ -2319,7 +2337,7 @@
<xsd:element name="unique-constraint" type="orm:unique-constraint" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="index" type="orm:index" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="table" type="xsd:string"/>
<xsd:attribute name="catalog" type="xsd:string"/>
<xsd:attribute name="schema" type="xsd:string"/>
Expand All @@ -2328,6 +2346,8 @@
<xsd:attribute name="pk-column-value" type="xsd:string"/>
<xsd:attribute name="initial-value" type="xsd:int"/>
<xsd:attribute name="allocation-size" type="xsd:int"/>
<xsd:attribute name="comment" type="xsd:string"/>
<xsd:attribute name="options" type="xsd:string"/>
</xsd:complexType>

<!-- **************************************************** -->
Expand Down Expand Up @@ -2558,8 +2578,8 @@
<xsd:sequence>
<xsd:element name="parameter" type="orm:configuration-parameter" minOccurs="0" maxOccurs="unbounded" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string"/>
<xsd:attribute name="class" use="required" type="xsd:string"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="class" type="xsd:string" use="required" />
</xsd:complexType>


Expand Down Expand Up @@ -2909,10 +2929,10 @@
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<!-- hbm: Check constraint -->
<xsd:element name="check" type="orm:check-constraint" minOccurs="0" />
<!-- hbm: SQL comment to be applied to the column on export -->
<xsd:element name="comment" type="xsd:string" minOccurs="0" />
<!-- hbm: Check constraint -->
<xsd:element name="check" type="xsd:string" minOccurs="0" />
<!-- hbm: Column default -->
<xsd:element name="default" type="xsd:string" minOccurs="0" />
<!-- hbm: Read fragment -->
Expand All @@ -2926,13 +2946,33 @@
<xsd:attribute name="insertable" type="xsd:boolean"/>
<xsd:attribute name="updatable" type="xsd:boolean"/>
<xsd:attribute name="column-definition" type="xsd:string"/>
<xsd:attribute name="options" type="xsd:string"/>
<xsd:attribute name="table" type="xsd:string"/>
<xsd:attribute name="length" type="xsd:int"/>
<xsd:attribute name="precision" type="xsd:int"/>
<xsd:attribute name="scale" type="xsd:int"/>
</xsd:complexType>


<!-- **************************************************** -->

<xsd:complexType name="check-constraint">
<xsd:annotation>
<xsd:documentation>
@Target({}) @Retention(RUNTIME)
public @interface CheckConstraint {
String name() default "";
String constraint();
String options() default "";
}
</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="constraint" type="xsd:string" use="required"/>
<xsd:attribute name="options" type="xsd:string"/>
</xsd:complexType>


<!-- **************************************************** -->

<xsd:complexType name="convert">
Expand Down Expand Up @@ -3076,6 +3116,6 @@
See `@org.hibernate.annotations.UuidGenerator`
</xsd:documentation>
</xsd:annotation>
<xsd:attribute name="style" type="orm:uuid-generator-style" use="required"/>
<xsd:attribute name="style" type="orm:uuid-generator-style" default="auto"/>
</xsd:complexType>
</xsd:schema>
48 changes: 41 additions & 7 deletions hibernate-orm/src/main/xjb/mapping-bindings.xjb
Original file line number Diff line number Diff line change
Expand Up @@ -381,21 +381,55 @@
<property name="caching"/>
</bindings>
</bindings>
<bindings node="//xsd:complexType[@name='table']">
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbTableMapping</inheritance:implements>
<bindings node=".//xsd:attribute[@name='options']">
<property name="optionsAttribute"/>
</bindings>
<bindings node=".//xsd:attribute[@name='comment']">
<property name="commentAttribute"/>
</bindings>
</bindings>

<bindings node="//xsd:complexType[@name='secondary-table']">
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbSchemaAware</inheritance:implements>
<bindings node="//xsd:complexType[@name='check-constraint']">
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbCheckConstraint</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='table']">
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbSchemaAware</inheritance:implements>

<bindings node="//xsd:complexType[@name='secondary-table']">
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbTableMapping</inheritance:implements>
<bindings node=".//xsd:attribute[@name='options']">
<property name="optionsAttribute"/>
</bindings>
<bindings node=".//xsd:attribute[@name='comment']">
<property name="commentAttribute"/>
</bindings>
</bindings>
<bindings node="//xsd:complexType[@name='join-table']">
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbSchemaAware</inheritance:implements>
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbTableMapping</inheritance:implements>
<bindings node=".//xsd:attribute[@name='options']">
<property name="optionsAttribute"/>
</bindings>
<bindings node=".//xsd:attribute[@name='comment']">
<property name="commentAttribute"/>
</bindings>
</bindings>
<bindings node="//xsd:complexType[@name='collection-table']">
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbSchemaAware</inheritance:implements>
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbTableMapping</inheritance:implements>
<bindings node=".//xsd:attribute[@name='options']">
<property name="optionsAttribute"/>
</bindings>
<bindings node=".//xsd:attribute[@name='comment']">
<property name="commentAttribute"/>
</bindings>
</bindings>
<bindings node="//xsd:complexType[@name='table-generator']">
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbSchemaAware</inheritance:implements>
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbTableMapping</inheritance:implements>
<bindings node=".//xsd:attribute[@name='options']">
<property name="optionsAttribute"/>
</bindings>
<bindings node=".//xsd:attribute[@name='comment']">
<property name="commentAttribute"/>
</bindings>
</bindings>
<bindings node="//xsd:complexType[@name='sequence-generator']">
<inheritance:implements>org.hibernate.boot.jaxb.mapping.spi.JaxbSchemaAware</inheritance:implements>
Expand Down

0 comments on commit e1d1ae7

Please sign in to comment.