From f17c0f7a03046a0b654b89af3256f2b9ba35907f Mon Sep 17 00:00:00 2001 From: Nathan Xu Date: Mon, 19 Oct 2020 09:08:57 -0400 Subject: [PATCH 1/4] HHH-14234 fix CI building error on non-H2 dialect --- ...edTablePhysicalIncludedTableConstraintTest.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/test/inheritance/DenormalizedTablePhysicalIncludedTableConstraintTest.java b/hibernate-core/src/test/java/org/hibernate/test/inheritance/DenormalizedTablePhysicalIncludedTableConstraintTest.java index aaba275ab2..a4375db86a 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/inheritance/DenormalizedTablePhysicalIncludedTableConstraintTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/inheritance/DenormalizedTablePhysicalIncludedTableConstraintTest.java @@ -12,7 +12,9 @@ import javax.persistence.Table; import javax.persistence.UniqueConstraint; import org.hibernate.cfg.AvailableSettings; +import org.hibernate.dialect.H2Dialect; +import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; import org.junit.Test; @@ -22,6 +24,11 @@ import org.junit.Test; * @author Nathan Xu */ @TestForIssue( jiraKey = "HHH-14234" ) +@RequiresDialect( + value = H2Dialect.class, + comment = "This test relies on 'hibernate.hbm2ddl.halt_on_error', only tested on h2; " + + "other dialects might be broken due to irrelevant reason (e.g. not supporting 'if exists' while dropping tables)." +) public class DenormalizedTablePhysicalIncludedTableConstraintTest extends BaseNonConfigCoreFunctionalTestCase { @Override @@ -40,13 +47,12 @@ public class DenormalizedTablePhysicalIncludedTableConstraintTest extends BaseNo @Test public void testUniqueConstraintFromSupTableNotAppliedToSubTable() { // Unique constraint should be unique in db - // Without fixing, exception will be thrown when unique constraint in 'SUPTABLE' is applied to 'SUBTABLE' as well - // Both table names are uppercase to accommodate HANA dialect (see https://stackoverflow.com/questions/29974507/sap-hana-invalid-table-name) + // Without fixing, exception will be thrown when unique constraint in 'supTable' is applied to 'subTable' as well } @Entity(name = "SuperClass") @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) - @Table( name = "SUPTABLE", + @Table( name = "supTable", uniqueConstraints = { @UniqueConstraint( name = "UK", columnNames = {"colOne", "colTwo"}) @@ -66,7 +72,7 @@ public class DenormalizedTablePhysicalIncludedTableConstraintTest extends BaseNo } @Entity(name = "SubClass") - @Table( name = "SUBTABLE" ) + @Table( name = "subTable" ) static class SubClass extends SuperClass { @Column(name = "colThree") From d9ec18fad707b06172f4bb6355bc331165148f58 Mon Sep 17 00:00:00 2001 From: Daniel Wu Date: Tue, 20 Oct 2020 09:23:52 +0800 Subject: [PATCH 2/4] HHH-14268 Include stacktrace at WARN level in case of an error occurs when getting the connection metadata --- .../engine/jdbc/env/internal/JdbcEnvironmentInitiator.java | 2 +- .../main/java/org/hibernate/internal/CoreMessageLogger.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java index 70c44e310f..f9ce35afe4 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java @@ -129,7 +129,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator Date: Tue, 20 Oct 2020 12:12:13 +0100 Subject: [PATCH 3/4] HHH-14269 Confusing method names unableToObjectConnectionMetadata and unableToObjectConnectionToQueryMetadata --- .../jdbc/env/internal/JdbcEnvironmentInitiator.java | 2 +- .../java/org/hibernate/internal/CoreMessageLogger.java | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java index f9ce35afe4..d2563e4251 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/env/internal/JdbcEnvironmentInitiator.java @@ -118,7 +118,7 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator Date: Fri, 2 Oct 2020 11:01:47 -0400 Subject: [PATCH 4/4] HHH-14196 Add parsing of persistence.xml/orm.xml documents in the EE 9 namespace Signed-off-by: Scott Marlow --- .../stax/LocalXmlResourceResolver.java | 22 + .../hibernate/boot/xsd/ConfigXsdSupport.java | 24 +- .../hibernate/boot/xsd/LocalXsdResolver.java | 1 + .../hibernate/boot/xsd/MappingXsdSupport.java | 9 + .../hibernate/cfg/EJB3DTDEntityResolver.java | 30 +- .../resources/org/hibernate/jpa/orm_3_0.xsd | 2324 +++++++++++++++++ .../org/hibernate/jpa/persistence_3_0.xsd | 342 +++ .../test/annotations/xml/ejb3/orm5.xml | 4 +- 8 files changed, 2751 insertions(+), 5 deletions(-) create mode 100644 hibernate-core/src/main/resources/org/hibernate/jpa/orm_3_0.xsd create mode 100644 hibernate-core/src/main/resources/org/hibernate/jpa/persistence_3_0.xsd diff --git a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/LocalXmlResourceResolver.java b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/LocalXmlResourceResolver.java index 537c348ffc..89a749a2d1 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/LocalXmlResourceResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/LocalXmlResourceResolver.java @@ -42,6 +42,12 @@ public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver { else if ( JPA_XSD_MAPPING.matches( namespace ) ) { return openUrlStream( JPA_XSD_MAPPING.getMappedLocalUrl() ); } + else if ( PERSISTENCE_ORM_XSD_MAPPING.matches( namespace ) ) { + return openUrlStream( PERSISTENCE_ORM_XSD_MAPPING.getMappedLocalUrl() ); + } + else if ( PERSISTENCE_ORM_XSD_MAPPING2.matches( namespace ) ) { + return openUrlStream( PERSISTENCE_ORM_XSD_MAPPING2.getMappedLocalUrl() ); + } else if ( HBM_XSD_MAPPING.matches( namespace ) ) { return openUrlStream( HBM_XSD_MAPPING.getMappedLocalUrl() ); } @@ -152,7 +158,23 @@ public class LocalXmlResourceResolver implements javax.xml.stream.XMLResolver { "http://xmlns.jcp.org/xml/ns/persistence/orm", "org/hibernate/jpa/orm_2_1.xsd" ); + + /** + * Maps the namespace for the orm.xml xsd for Jakarta Persistence 2.2 + */ + public static final NamespaceSchemaMapping PERSISTENCE_ORM_XSD_MAPPING = new NamespaceSchemaMapping( + "http://xmlns.jcp.org/xml/ns/persistence/orm", + "org/hibernate/jpa/orm_2_2.xsd" + ); + /** + * Maps the namespace for the orm.xml xsd for Jakarta Persistence 3.0 + */ + public static final NamespaceSchemaMapping PERSISTENCE_ORM_XSD_MAPPING2 = new NamespaceSchemaMapping( + "https://jakarta.ee/xml/ns/persistence/orm", + "org/hibernate/jpa/orm_3_0.xsd" + ); + public static final NamespaceSchemaMapping HBM_XSD_MAPPING = new NamespaceSchemaMapping( "http://www.hibernate.org/xsd/orm/hbm", "org/hibernate/xsd/mapping/legacy-mapping-4.0.xsd" diff --git a/hibernate-core/src/main/java/org/hibernate/boot/xsd/ConfigXsdSupport.java b/hibernate-core/src/main/java/org/hibernate/boot/xsd/ConfigXsdSupport.java index 25da42f2b9..d68773b857 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/xsd/ConfigXsdSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/xsd/ConfigXsdSupport.java @@ -26,9 +26,10 @@ public class ConfigXsdSupport { * 1: JPA 1.0 * 2: JPA 2.0 * 3: JPA 2.1 - * 4: JPA 2.2 + * 4: JPA 2.2 (default) + * 5: Jakarta Persistence 3.0 */ - private static final XsdDescriptor[] xsdCache = new XsdDescriptor[5]; + private static final XsdDescriptor[] xsdCache = new XsdDescriptor[6]; public XsdDescriptor latestJpaDescriptor() { return getJPA22(); @@ -48,6 +49,9 @@ public class ConfigXsdSupport { case "2.2": { return getJPA22(); } + case "3.0": { + return getJPA30(); + } default: { throw new IllegalArgumentException( "Unrecognized JPA persistence.xml XSD version : `" + version + "`" ); } @@ -134,4 +138,20 @@ public class ConfigXsdSupport { } } + private XsdDescriptor getJPA30() { + final int index = 5; + synchronized ( xsdCache ) { + XsdDescriptor jpa30 = xsdCache[index]; + if ( jpa30 == null ) { + jpa30 = LocalXsdResolver.buildXsdDescriptor( + "org/hibernate/jpa/persistence_3_0.xsd", + "3.0", + "https://jakarta.ee/xml/ns/persistence" + ); + xsdCache[index] = jpa30; + } + return jpa30; + } + } + } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/xsd/LocalXsdResolver.java b/hibernate-core/src/main/java/org/hibernate/boot/xsd/LocalXsdResolver.java index 7b312d1111..2215f8108c 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/xsd/LocalXsdResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/xsd/LocalXsdResolver.java @@ -43,6 +43,7 @@ public class LocalXsdResolver { case "2.0": case "2.1": case "2.2": + case "3.0": return true; default: return false; diff --git a/hibernate-core/src/main/java/org/hibernate/boot/xsd/MappingXsdSupport.java b/hibernate-core/src/main/java/org/hibernate/boot/xsd/MappingXsdSupport.java index 7ed1453110..33a3719270 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/xsd/MappingXsdSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/xsd/MappingXsdSupport.java @@ -44,6 +44,12 @@ public class MappingXsdSupport { "http://xmlns.jcp.org/xml/ns/persistence" ); + private final XsdDescriptor jpa30 = LocalXsdResolver.buildXsdDescriptor( + "org/hibernate/jpa/orm_3_0.xsd", + "3.0", + "https://jakarta.ee/xml/ns/persistence/orm" + ); + private final XsdDescriptor hbmXml = LocalXsdResolver.buildXsdDescriptor( "org/hibernate/xsd/mapping/legacy-mapping-4.0.xsd", "4.0", @@ -72,6 +78,9 @@ public class MappingXsdSupport { case "2.2": { return jpa22; } + case "3.0:": { + return jpa30; + } default: { throw new IllegalArgumentException( "Unrecognized JPA orm.xml XSD version : `" + version + "`" ); } diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/EJB3DTDEntityResolver.java b/hibernate-core/src/main/java/org/hibernate/cfg/EJB3DTDEntityResolver.java index 8fa3956e22..4adec44fdf 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/EJB3DTDEntityResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/EJB3DTDEntityResolver.java @@ -41,13 +41,27 @@ public class EJB3DTDEntityResolver extends DTDEntityResolver { public InputSource resolveEntity(String publicId, String systemId) { LOG.tracev( "Resolving XML entity {0} : {1}", publicId, systemId ); if ( systemId != null ) { - if ( systemId.endsWith( "orm_2_1.xsd" ) ) { + if ( systemId.endsWith( "orm_3_0.xsd" ) ) { + InputStream dtdStream = getStreamFromClasspath( "orm_3_0.xsd" ); + final InputSource source = buildInputSource( publicId, systemId, dtdStream, false ); + if ( source != null ) { + return source; + } + } + else if ( systemId.endsWith( "orm_2_1.xsd" ) ) { InputStream dtdStream = getStreamFromClasspath( "orm_2_1.xsd" ); final InputSource source = buildInputSource( publicId, systemId, dtdStream, false ); if ( source != null ) { return source; } } + else if ( systemId.endsWith( "orm_2_2.xsd" ) ) { + InputStream dtdStream = getStreamFromClasspath( "orm_2_2.xsd" ); + final InputSource source = buildInputSource( publicId, systemId, dtdStream, false ); + if ( source != null ) { + return source; + } + } else if ( systemId.endsWith( "orm_2_0.xsd" ) ) { InputStream dtdStream = getStreamFromClasspath( "orm_2_0.xsd" ); final InputSource source = buildInputSource( publicId, systemId, dtdStream, false ); @@ -62,6 +76,20 @@ public class EJB3DTDEntityResolver extends DTDEntityResolver { return source; } } + else if ( systemId.endsWith( "persistence_3_0.xsd" ) ) { + InputStream dtdStream = getStreamFromClasspath( "persistence_3_0.xsd" ); + final InputSource source = buildInputSource( publicId, systemId, dtdStream, true ); + if ( source != null ) { + return source; + } + } + else if ( systemId.endsWith( "persistence_2_2.xsd" ) ) { + InputStream dtdStream = getStreamFromClasspath( "persistence_2_2.xsd" ); + final InputSource source = buildInputSource( publicId, systemId, dtdStream, true ); + if ( source != null ) { + return source; + } + } else if ( systemId.endsWith( "persistence_2_1.xsd" ) ) { InputStream dtdStream = getStreamFromClasspath( "persistence_2_1.xsd" ); final InputSource source = buildInputSource( publicId, systemId, dtdStream, true ); diff --git a/hibernate-core/src/main/resources/org/hibernate/jpa/orm_3_0.xsd b/hibernate-core/src/main/resources/org/hibernate/jpa/orm_3_0.xsd new file mode 100644 index 0000000000..233d98f6ea --- /dev/null +++ b/hibernate-core/src/main/resources/org/hibernate/jpa/orm_3_0.xsd @@ -0,0 +1,2324 @@ + + + + + + + + + ... + + + + ]]> + + + + + + + + + + + + + + + + + + The entity-mappings element is the root element of a mapping + file. It contains the following four types of elements: + + 1. The persistence-unit-metadata element contains metadata + for the entire persistence unit. It is undefined if this element + occurs in multiple mapping files within the same persistence unit. + + 2. The package, schema, catalog and access elements apply to all of + the entity, mapped-superclass and embeddable elements defined in + the same file in which they occur. + + 3. The sequence-generator, table-generator, converter, named-query, + named-native-query, named-stored-procedure-query, and + sql-result-set-mapping elements are global to the persistence + unit. It is undefined to have more than one sequence-generator + or table-generator of the same name in the same or different + mapping files in a persistence unit. It is undefined to have + more than one named-query, named-native-query, sql-result-set-mapping, + or named-stored-procedure-query of the same name in the same + or different mapping files in a persistence unit. It is also + undefined to have more than one converter for the same target + type in the same or different mapping files in a persistence unit. + + 4. The entity, mapped-superclass and embeddable elements each define + the mapping information for a managed persistent class. The mapping + information contained in these elements may be complete or it may + be partial. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Metadata that applies to the persistence unit and not just to + the mapping file in which it is contained. + + If the xml-mapping-metadata-complete element is specified, + the complete set of mapping metadata for the persistence unit + is contained in the XML mapping files for the persistence unit. + + + + + + + + + + + + + + + + + These defaults are applied to the persistence unit as a whole + unless they are overridden by local annotation or XML + element settings. + + schema - Used as the schema for all tables, secondary tables, join + tables, collection tables, sequence generators, and table + generators that apply to the persistence unit + catalog - Used as the catalog for all tables, secondary tables, join + tables, collection tables, sequence generators, and table + generators that apply to the persistence unit + delimited-identifiers - Used to treat database identifiers as + delimited identifiers. + access - Used as the access type for all managed classes in + the persistence unit + cascade-persist - Adds cascade-persist to the set of cascade options + in all entity relationships of the persistence unit + entity-listeners - List of default entity listeners to be invoked + on each entity in the persistence unit. + + + + + + + + + + + + + + + + + + + + Defines the settings and mappings for an entity. Is allowed to be + sparsely populated and used in conjunction with the annotations. + Alternatively, the metadata-complete attribute can be used to + indicate that no annotations on the entity class (and its fields + or properties) are to be processed. If this is the case then + the defaulting rules for the entity and its subelements will + be recursively applied. + + @Target(TYPE) @Retention(RUNTIME) + public @interface Entity { + String name() default ""; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This element determines how the persistence provider accesses the + state of an entity or embedded object. + + + + + + + + + + + + + + + + @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) + public @interface AssociationOverride { + String name(); + JoinColumn[] joinColumns() default{}; + JoinTable joinTable() default @JoinTable; + } + + + + + + + + + + + + + + + + + + + + + + + @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) + public @interface AttributeOverride { + String name(); + Column column(); + } + + + + + + + + + + + + + + + + + This element contains the entity field or property mappings. + It may be sparsely populated to include only a subset of the + fields or properties. If metadata-complete for the entity is true + then the remainder of the attributes will be defaulted according + to the default rules. + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Basic { + FetchType fetch() default EAGER; + boolean optional() default true; + } + + + + + + + + + + + + + + + + + + + + + + + + + public enum CascadeType { ALL, PERSIST, MERGE, REMOVE, REFRESH, DETACH}; + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface CollectionTable { + String name() default ""; + String catalog() default ""; + String schema() default ""; + JoinColumn[] joinColumns() default {}; + UniqueConstraint[] uniqueConstraints() default {}; + Index[] indexes() default {}; + } + + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Column { + String name() default ""; + boolean unique() default false; + boolean nullable() default true; + boolean insertable() default true; + boolean updatable() default true; + String columnDefinition() default ""; + String table() default ""; + int length() default 255; + int precision() default 0; // decimal precision + int scale() default 0; // decimal scale + } + + + + + + + + + + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface ColumnResult { + String name(); + Class type() default void.class; + } + + + + + + + + + + + + + + public enum ConstraintMode {CONSTRAINT, NO_CONSTRAINT, PROVIDER_DEFAULT}; + + + + + + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface ConstructorResult { + Class targetClass(); + ColumnResult[] columns(); + } + + + + + + + + + + + + + + + + @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) + public @interface Convert { + Class converter() default void.class; + String attributeName() default ""; + boolean disableConversion() default false; + } + + + + + + + + + + + + + + + + + + @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) + public @interface Converter { + boolean autoApply() default false; + } + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface DiscriminatorColumn { + String name() default "DTYPE"; + DiscriminatorType discriminatorType() default STRING; + String columnDefinition() default ""; + int length() default 31; + } + + + + + + + + + + + + + + + + public enum DiscriminatorType { STRING, CHAR, INTEGER }; + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface DiscriminatorValue { + String value(); + } + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface ElementCollection { + Class targetClass() default void.class; + FetchType fetch() default LAZY; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Defines the settings and mappings for embeddable objects. Is + allowed to be sparsely populated and used in conjunction with + the annotations. Alternatively, the metadata-complete attribute + can be used to indicate that no annotations are to be processed + in the class. If this is the case then the defaulting rules will + be recursively applied. + + @Target({TYPE}) @Retention(RUNTIME) + public @interface Embeddable {} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Embedded {} + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface EmbeddedId {} + + + + + + + + + + + + + + + + + Defines an entity listener to be invoked at lifecycle events + for the entities that list this listener. + + + + + + + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface EntityListeners { + Class[] value(); + } + + + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface EntityResult { + Class entityClass(); + FieldResult[] fields() default {}; + String discriminatorColumn() default ""; + } + + + + + + + + + + + + + + + + + public enum EnumType { + ORDINAL, + STRING + } + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Enumerated { + EnumType value() default ORDINAL; + } + + + + + + + + + + + + + public enum FetchType { LAZY, EAGER }; + + + + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface FieldResult { + String name(); + String column(); + } + + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface ForeignKey { + String name() default ""; + ConstraintMode value() default CONSTRAINT; + String foreign-key-definition() default ""; + + Note that the elements that embed the use of the annotation + default this use as @ForeignKey(PROVIDER_DEFAULT). + + } + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface GeneratedValue { + GenerationType strategy() default AUTO; + String generator() default ""; + } + + + + + + + + + + + + + + public enum GenerationType { TABLE, SEQUENCE, IDENTITY, AUTO }; + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Id {} + + + + + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface IdClass { + Class value(); + } + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface Index { + String name() default ""; + String columnList(); + boolean unique() default false; + } + + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface Inheritance { + InheritanceType strategy() default SINGLE_TABLE; + } + + + + + + + + + + + + + public enum InheritanceType + { SINGLE_TABLE, JOINED, TABLE_PER_CLASS}; + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface JoinColumn { + String name() default ""; + String referencedColumnName() default ""; + boolean unique() default false; + boolean nullable() default true; + boolean insertable() default true; + boolean updatable() default true; + String columnDefinition() default ""; + String table() default ""; + ForeignKey foreignKey() default @ForeignKey(); + } + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface JoinTable { + String name() default ""; + String catalog() default ""; + String schema() default ""; + JoinColumn[] joinColumns() default {}; + JoinColumn[] inverseJoinColumns() default {}; + UniqueConstraint[] uniqueConstraints() default {}; + Index[] indexes() default {}; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Lob {} + + + + + + + + + + + + public enum LockModeType { READ, WRITE, OPTIMISTIC, OPTIMISTIC_FORCE_INCREMENT, PESSIMISTIC_READ, PESSIMISTIC_WRITE, PESSIMISTIC_FORCE_INCREMENT, NONE}; + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface ManyToMany { + Class targetEntity() default void.class; + CascadeType[] cascade() default {}; + FetchType fetch() default LAZY; + String mappedBy() default ""; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface ManyToOne { + Class targetEntity() default void.class; + CascadeType[] cascade() default {}; + FetchType fetch() default EAGER; + boolean optional() default true; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface MapKey { + String name() default ""; + } + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface MapKeyClass { + Class value(); + } + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface MapKeyColumn { + String name() default ""; + boolean unique() default false; + boolean nullable() default false; + boolean insertable() default true; + boolean updatable() default true; + String columnDefinition() default ""; + String table() default ""; + int length() default 255; + int precision() default 0; // decimal precision + int scale() default 0; // decimal scale + } + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface MapKeyJoinColumn { + String name() default ""; + String referencedColumnName() default ""; + boolean unique() default false; + boolean nullable() default false; + boolean insertable() default true; + boolean updatable() default true; + String columnDefinition() default ""; + String table() default ""; + } + + + + + + + + + + + + + + + + + + + + + Defines the settings and mappings for a mapped superclass. Is + allowed to be sparsely populated and used in conjunction with + the annotations. Alternatively, the metadata-complete attribute + can be used to indicate that no annotations are to be processed + If this is the case then the defaulting rules will be recursively + applied. + + @Target(TYPE) @Retention(RUNTIME) + public @interface MappedSuperclass{} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface NamedAttributeNode { + String value(); + String subgraph() default ""; + String keySubgraph() default ""; + } + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface NamedEntityGraph { + String name() default ""; + NamedAttributeNode[] attributeNodes() default {}; + boolean includeAllAttributes() default false; + NamedSubgraph[] subgraphs() default {}; + NamedSubGraph[] subclassSubgraphs() default {}; + } + + + + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface NamedNativeQuery { + String name(); + String query(); + QueryHint[] hints() default {}; + Class resultClass() default void.class; + String resultSetMapping() default ""; //named SqlResultSetMapping + } + + + + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface NamedQuery { + String name(); + String query(); + LockModeType lockMode() default NONE; + QueryHint[] hints() default {}; + } + + + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface NamedStoredProcedureQuery { + String name(); + String procedureName(); + StoredProcedureParameter[] parameters() default {}; + Class[] resultClasses() default {}; + String[] resultSetMappings() default{}; + QueryHint[] hints() default {}; + } + + + + + + + + + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface NamedSubgraph { + String name(); + Class type() default void.class; + NamedAttributeNode[] attributeNodes(); + } + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface OneToMany { + Class targetEntity() default void.class; + CascadeType[] cascade() default {}; + FetchType fetch() default LAZY; + String mappedBy() default ""; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface OneToOne { + Class targetEntity() default void.class; + CascadeType[] cascade() default {}; + FetchType fetch() default EAGER; + boolean optional() default true; + String mappedBy() default ""; + boolean orphanRemoval() default false; + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface OrderBy { + String value() default ""; + } + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface OrderColumn { + String name() default ""; + boolean nullable() default true; + boolean insertable() default true; + boolean updatable() default true; + String columnDefinition() default ""; + } + + + + + + + + + + + + + + + + + public enum ParameterMode { IN, INOUT, OUT, REF_CURSOR}; + + + + + + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PostLoad {} + + + + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PostPersist {} + + + + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PostRemove {} + + + + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PostUpdate {} + + + + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PrePersist {} + + + + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PreRemove {} + + + + + + + + + + + + + + + + @Target({METHOD}) @Retention(RUNTIME) + public @interface PreUpdate {} + + + + + + + + + + + + + + + + @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) + public @interface PrimaryKeyJoinColumn { + String name() default ""; + String referencedColumnName() default ""; + String columnDefinition() default ""; + } + + + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface QueryHint { + String name(); + String value(); + } + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface SecondaryTable { + String name(); + String catalog() default ""; + String schema() default ""; + PrimaryKeyJoinColumn[] pkJoinColumns() default {}; + UniqueConstraint[] uniqueConstraints() default {}; + Index[] indexes() default {}; + } + + + + + + + + + + + + + + + + + + + + + + + @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) + public @interface SequenceGenerator { + String name(); + String sequenceName() default ""; + String catalog() default ""; + String schema() default ""; + int initialValue() default 1; + int allocationSize() default 50; + } + + + + + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface SqlResultSetMapping { + String name(); + EntityResult[] entities() default {}; + ConstructorResult[] classes() default{}; + ColumnResult[] columns() default {}; + } + + + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface StoredProcedureParameter { + String name() default ""; + ParameterMode mode() default ParameterMode.IN; + Class type(); + } + + + + + + + + + + + + + + + + + + @Target({TYPE}) @Retention(RUNTIME) + public @interface Table { + String name() default ""; + String catalog() default ""; + String schema() default ""; + UniqueConstraint[] uniqueConstraints() default {}; + Index[] indexes() default {}; + } + + + + + + + + + + + + + + + + + + + @Target({TYPE, METHOD, FIELD}) @Retention(RUNTIME) + public @interface TableGenerator { + String name(); + String table() default ""; + String catalog() default ""; + String schema() default ""; + String pkColumnName() default ""; + String valueColumnName() default ""; + String pkColumnValue() default ""; + int initialValue() default 0; + int allocationSize() default 50; + UniqueConstraint[] uniqueConstraints() default {}; + Indexes[] indexes() default {}; + } + + + + + + + + + + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Temporal { + TemporalType value(); + } + + + + + + + + + + + + + public enum TemporalType { + DATE, // java.sql.Date + TIME, // java.sql.Time + TIMESTAMP // java.sql.Timestamp + } + + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Transient {} + + + + + + + + + + + + + @Target({}) @Retention(RUNTIME) + public @interface UniqueConstraint { + String name() default ""; + String[] columnNames(); + } + + + + + + + + + + + + + + + + @Target({METHOD, FIELD}) @Retention(RUNTIME) + public @interface Version {} + + + + + + + + + + + + diff --git a/hibernate-core/src/main/resources/org/hibernate/jpa/persistence_3_0.xsd b/hibernate-core/src/main/resources/org/hibernate/jpa/persistence_3_0.xsd new file mode 100644 index 0000000000..e2a2943937 --- /dev/null +++ b/hibernate-core/src/main/resources/org/hibernate/jpa/persistence_3_0.xsd @@ -0,0 +1,342 @@ + + + + + + + + + ... + + + ]]> + + + + + + + + + + + + + + + + + + + + + + Configuration of a persistence unit. + + + + + + + + + + + + Description of this persistence unit. + + + + + + + + + + + + Provider class that supplies EntityManagers for this + persistence unit. + + + + + + + + + + + + The container-specific name of the JTA datasource to use. + + + + + + + + + + + + The container-specific name of a non-JTA datasource to use. + + + + + + + + + + + + File containing mapping information. Loaded as a resource + by the persistence provider. + + + + + + + + + + + + Jar file that is to be scanned for managed classes. + + + + + + + + + + + + Managed class to be included in the persistence unit and + to scan for annotations. It should be annotated + with either @Entity, @Embeddable or @MappedSuperclass. + + + + + + + + + + + + When set to true then only listed classes and jars will + be scanned for persistent classes, otherwise the + enclosing jar or directory will also be scanned. + Not applicable to Java SE persistence units. + + + + + + + + + + + + Defines whether caching is enabled for the + persistence unit if caching is supported by the + persistence provider. When set to ALL, all entities + will be cached. When set to NONE, no entities will + be cached. When set to ENABLE_SELECTIVE, only entities + specified as cacheable will be cached. When set to + DISABLE_SELECTIVE, entities specified as not cacheable + will not be cached. When not specified or when set to + UNSPECIFIED, provider defaults may apply. + + + + + + + + + + + + The validation mode to be used for the persistence unit. + + + + + + + + + + + + + A list of standard and vendor-specific properties + and hints. + + + + + + + + + A name-value pair. + + + + + + + + + + + + + + + + + + + + Name used in code to reference this persistence unit. + + + + + + + + + + + + Type of transactions used by EntityManagers from this + persistence unit. + + + + + + + + + + + + + + + + + + + public enum PersistenceUnitTransactionType {JTA, RESOURCE_LOCAL}; + + + + + + + + + + + + + + + + public enum SharedCacheMode { ALL, NONE, ENABLE_SELECTIVE, DISABLE_SELECTIVE, UNSPECIFIED}; + + + + + + + + + + + + + + + + + + + public enum ValidationMode { AUTO, CALLBACK, NONE}; + + + + + + + + + + + diff --git a/hibernate-core/src/test/resources/org/hibernate/test/annotations/xml/ejb3/orm5.xml b/hibernate-core/src/test/resources/org/hibernate/test/annotations/xml/ejb3/orm5.xml index 5c3974e8f9..710606f22e 100644 --- a/hibernate-core/src/test/resources/org/hibernate/test/annotations/xml/ejb3/orm5.xml +++ b/hibernate-core/src/test/resources/org/hibernate/test/annotations/xml/ejb3/orm5.xml @@ -9,7 +9,7 @@ org.hibernate.test.annotations.xml.ejb3 @@ -24,4 +24,4 @@ - \ No newline at end of file +