diff --git a/documentation/src/main/asciidoc/userguide/chapters/domain/collections.adoc b/documentation/src/main/asciidoc/userguide/chapters/domain/collections.adoc
index 59e0a5daa5a8..cd32e16b48d7 100644
--- a/documentation/src/main/asciidoc/userguide/chapters/domain/collections.adoc
+++ b/documentation/src/main/asciidoc/userguide/chapters/domain/collections.adoc
@@ -1,12 +1,11 @@
[[collections]]
=== Collections
-:majorMinorVersion: 6.2
:root-project-dir: ../../../../../../..
:core-project-dir: {root-project-dir}/hibernate-core
:core-test-base: {core-project-dir}/src/test/java
:example-dir-collection: {core-test-base}/org/hibernate/orm/test/mapping/collections
:docs-base: https://docs.jboss.org/hibernate/orm/{majorMinorVersion}
-:javadoc-base: {docs-base}/javadoc
+:javadoc-base: {docs-base}/javadocs
:java-javadoc-base: https://docs.oracle.com/en/java/javase/11/docs/api/java.base
:extrasdir: extras/collections
@@ -285,7 +284,16 @@ is available to have Hibernate interpret a `List` with no `@OrderColumn` and no
An ID_BAG is similar to a BAG, except that it maps a generated, per-row identifier into the collection
-table. `@CollectionId` is the annotation to configure this identifier
+table. `@CollectionId` is the annotation to configure this identifier.
+
+For details about defining an id-bad identifier, see the Javadocs for:
+
+* link:{javadoc-base}/org/hibernate/annotations/CollectionId.html[@CollectionId]
+* link:{javadoc-base}/org/hibernate/annotations/CollectionIdJavaClass.html[@CollectionIdJavaClass]
+* link:{javadoc-base}/org/hibernate/annotations/CollectionIdJavaType.html[@CollectionIdJavaType]
+* link:{javadoc-base}/org/hibernate/annotations/CollectionIdJdbcType.html[@CollectionIdJdbcType]
+* link:{javadoc-base}/org/hibernate/annotations/CollectionIdJdbcTypeCode.html[@CollectionIdJdbcTypeCode]
+* link:{javadoc-base}/org/hibernate/annotations/CollectionIdType.html[@CollectionIdType]
// todo (6.0) - finish
diff --git a/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/AltibaseFunctionsTest.java b/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/AltibaseFunctionsTest.java
index 17d8f7867111..b5f6d6edc3e7 100644
--- a/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/AltibaseFunctionsTest.java
+++ b/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/AltibaseFunctionsTest.java
@@ -23,10 +23,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
-@DomainModel(
- annotatedClasses = { Person.class },
- xmlMappings = "org/hibernate/community/dialect/Person.hbm.xml"
-)
+@DomainModel(annotatedClasses = Person.class)
@RequiresDialect(AltibaseDialect.class)
@SessionFactory
public class AltibaseFunctionsTest {
diff --git a/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/Person.java b/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/Person.java
index 5a150d6442cb..de3629a69140 100644
--- a/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/Person.java
+++ b/hibernate-community-dialects/src/test/java/org/hibernate/community/dialect/Person.java
@@ -4,9 +4,20 @@
*/
package org.hibernate.community.dialect;
-import java.sql.*;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.SequenceGenerator;
+import java.sql.Date;
+import java.sql.Blob;
+import java.sql.Clob;
+
+@Entity
public class Person {
+ @Id
+ @GeneratedValue
+ @SequenceGenerator(sequenceName = "PERSON_SEQ")
private int id;
private String name;
private Date birthDate;
diff --git a/hibernate-community-dialects/src/test/resources/org/hibernate/community/dialect/Person.hbm.xml b/hibernate-community-dialects/src/test/resources/org/hibernate/community/dialect/Person.hbm.xml
deleted file mode 100644
index a1565790befe..000000000000
--- a/hibernate-community-dialects/src/test/resources/org/hibernate/community/dialect/Person.hbm.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
- PERSON_SEQ
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/CollectionId.java b/hibernate-core/src/main/java/org/hibernate/annotations/CollectionId.java
index 96a2b7b1c0c6..647e6665bde1 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/CollectionId.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/CollectionId.java
@@ -16,7 +16,14 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
- * Describe an identifier column for a bag.
+ * Describe the identifier for an id-bag.
+ *
+ * @see CollectionIdJavaClass
+ * @see CollectionIdJavaType
+ * @see CollectionIdJdbcType
+ * @see CollectionIdJdbcTypeCode
+ * @see CollectionIdMutability
+ * @see CollectionIdType
*
* @author Emmanuel Bernard
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/CollectionIdJavaClass.java b/hibernate-core/src/main/java/org/hibernate/annotations/CollectionIdJavaClass.java
new file mode 100644
index 000000000000..8ae81cefe857
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/CollectionIdJavaClass.java
@@ -0,0 +1,40 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.annotations;
+
+import org.hibernate.Incubating;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Specifies the Java class to use for the {@linkplain CollectionId id} of an id-bag mapping.
+ * An alternative to {@linkplain CollectionIdJavaType}. E.g.
+ *
+ *
+ * @Bag
+ * @CollectionId(generator="increment")
+ * @CollectionIdJavaClass(Integer.class)
+ * Collection<Person> authors;
+ *
+ *
+ * @since 7.1
+ *
+ * @author Steve Ebersole
+ */
+@Incubating
+@Target({METHOD, FIELD, ANNOTATION_TYPE})
+@Retention(RUNTIME)
+public @interface CollectionIdJavaClass {
+ /**
+ * The Java class to use as the collection-id.
+ */
+ Class> idType();
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/CollectionIdJavaType.java b/hibernate-core/src/main/java/org/hibernate/annotations/CollectionIdJavaType.java
index bd36b2f04a2b..f95d486fdaa4 100644
--- a/hibernate-core/src/main/java/org/hibernate/annotations/CollectionIdJavaType.java
+++ b/hibernate-core/src/main/java/org/hibernate/annotations/CollectionIdJavaType.java
@@ -18,6 +18,8 @@
/**
* Form of {@link JavaType} for describing the id of an id-bag mapping.
*
+ * @see CollectionIdJavaClass
+ *
* @since 6.0
*/
@Inherited
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbAnyMapping.java b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbAnyMapping.java
index 9578a294036a..fc65cd5e4799 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbAnyMapping.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbAnyMapping.java
@@ -4,6 +4,8 @@
*/
package org.hibernate.boot.jaxb.mapping.spi;
+import jakarta.persistence.DiscriminatorType;
+
import java.util.List;
/**
@@ -29,6 +31,8 @@ public interface JaxbAnyMapping extends JaxbPersistentAttribute {
*/
interface Key {
List getColumns();
+ String getType();
+ String getJavaClass();
}
/**
@@ -42,6 +46,11 @@ interface Discriminator {
*/
JaxbColumnImpl getColumn();
+ /**
+ * The type of discriminator
+ */
+ DiscriminatorType getType();
+
/**
* Mapping of discriminator-values to the corresponding entity names
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbBasicMapping.java b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbBasicMapping.java
index a86b7fb15e6f..89da9c83b433 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbBasicMapping.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbBasicMapping.java
@@ -11,6 +11,12 @@
* @author Steve Ebersole
*/
public interface JaxbBasicMapping {
+ /**
+ * The attribute's name
+ */
+ String getName();
+ void setName(String name);
+
JaxbUserTypeImpl getType();
void setType(JaxbUserTypeImpl value);
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbEmbeddable.java b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbEmbeddable.java
index c5c23cd6d377..44950b752f2f 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbEmbeddable.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/jaxb/mapping/spi/JaxbEmbeddable.java
@@ -4,8 +4,13 @@
*/
package org.hibernate.boot.jaxb.mapping.spi;
+import org.checkerframework.checker.nullness.qual.Nullable;
+
/**
* @author Steve Ebersole
*/
public interface JaxbEmbeddable extends JaxbManagedType {
+ @Nullable
+ String getName();
+ void setName(@Nullable String name);
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java
index 6f343fb0e3d7..86123b42ac2d 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java
@@ -397,8 +397,21 @@ private void prepareCollectionId(MemberDetails attribute) {
implicitJavaTypeAccess = typeConfiguration -> null;
explicitJavaTypeAccess = typeConfiguration -> {
- final CollectionIdJavaType javaTypeAnn =
- attribute.locateAnnotationUsage( CollectionIdJavaType.class, getSourceModelContext() );
+ final CollectionIdJavaClass javaClassAnn = attribute.locateAnnotationUsage(
+ CollectionIdJavaClass.class,
+ getSourceModelContext()
+ );
+ if ( javaClassAnn != null ) {
+ return (BasicJavaType>) buildingContext
+ .getBootstrapContext()
+ .getTypeConfiguration()
+ .getJavaTypeRegistry()
+ .getDescriptor( javaClassAnn.idType() );
+ }
+ final CollectionIdJavaType javaTypeAnn = attribute.locateAnnotationUsage(
+ CollectionIdJavaType.class,
+ getSourceModelContext()
+ );
if ( javaTypeAnn != null ) {
final Class extends BasicJavaType>> javaTypeClass = javaTypeAnn.value();
if ( javaTypeClass != null ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java
index b994f1d4c715..2438615dea98 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java
@@ -17,57 +17,7 @@
import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
-import org.hibernate.annotations.Bag;
-import org.hibernate.annotations.Cache;
-import org.hibernate.annotations.CacheLayout;
-import org.hibernate.annotations.Cascade;
-import org.hibernate.annotations.Check;
-import org.hibernate.annotations.Checks;
-import org.hibernate.annotations.CollectionId;
-import org.hibernate.annotations.CollectionIdJavaType;
-import org.hibernate.annotations.CollectionIdJdbcType;
-import org.hibernate.annotations.CollectionIdJdbcTypeCode;
-import org.hibernate.annotations.CollectionType;
-import org.hibernate.annotations.Columns;
-import org.hibernate.annotations.CompositeType;
-import org.hibernate.annotations.Fetch;
-import org.hibernate.annotations.FetchProfileOverride;
-import org.hibernate.annotations.Filter;
-import org.hibernate.annotations.FilterJoinTable;
-import org.hibernate.annotations.Formula;
-import org.hibernate.annotations.HQLSelect;
-import org.hibernate.annotations.Immutable;
-import org.hibernate.annotations.LazyGroup;
-import org.hibernate.annotations.ListIndexBase;
-import org.hibernate.annotations.ListIndexJavaType;
-import org.hibernate.annotations.ListIndexJdbcType;
-import org.hibernate.annotations.ListIndexJdbcTypeCode;
-import org.hibernate.annotations.ManyToAny;
-import org.hibernate.annotations.MapKeyJavaType;
-import org.hibernate.annotations.MapKeyJdbcType;
-import org.hibernate.annotations.MapKeyJdbcTypeCode;
-import org.hibernate.annotations.MapKeyMutability;
-import org.hibernate.annotations.MapKeyType;
-import org.hibernate.annotations.NotFound;
-import org.hibernate.annotations.NotFoundAction;
-import org.hibernate.annotations.OnDelete;
-import org.hibernate.annotations.OnDeleteAction;
-import org.hibernate.annotations.OptimisticLock;
-import org.hibernate.annotations.Parameter;
-import org.hibernate.annotations.QueryCacheLayout;
-import org.hibernate.annotations.SQLDelete;
-import org.hibernate.annotations.SQLDeleteAll;
-import org.hibernate.annotations.SQLInsert;
-import org.hibernate.annotations.SQLJoinTableRestriction;
-import org.hibernate.annotations.SQLOrder;
-import org.hibernate.annotations.SQLRestriction;
-import org.hibernate.annotations.SQLSelect;
-import org.hibernate.annotations.SQLUpdate;
-import org.hibernate.annotations.SoftDelete;
-import org.hibernate.annotations.SortComparator;
-import org.hibernate.annotations.SortNatural;
-import org.hibernate.annotations.SqlFragmentAlias;
-import org.hibernate.annotations.Synchronize;
+import org.hibernate.annotations.*;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.models.annotations.internal.JoinColumnJpaAnnotation;
@@ -1004,6 +954,7 @@ private static CollectionClassification determineCollectionClassification(
}
if ( property.hasDirectAnnotationUsage( CollectionId.class )
+ || property.hasDirectAnnotationUsage( CollectionIdJavaClass.class )
|| property.hasDirectAnnotationUsage( CollectionIdJdbcType.class )
|| property.hasDirectAnnotationUsage( CollectionIdJdbcTypeCode.class )
|| property.hasDirectAnnotationUsage( CollectionIdJavaType.class ) ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ComponentPropertyHolder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ComponentPropertyHolder.java
index ec14d0ac22e8..e390b646709a 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ComponentPropertyHolder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ComponentPropertyHolder.java
@@ -341,13 +341,13 @@ public Column[] getOverriddenColumn(String propertyName) {
private String extractUserPropertyName(String redundantString, String propertyName) {
String className = component.getOwner().getClassName();
- boolean specialCase = propertyName.startsWith(className)
- && propertyName.length() > className.length() + 2 + redundantString.length() // .id.
- && propertyName.substring( className.length() + 1, className.length() + 1 + redundantString.length() )
- .equals(redundantString);
- if (specialCase) {
- //remove id we might be in a @IdClass case
- return className + propertyName.substring( className.length() + 1 + redundantString.length() );
+ if ( className != null && propertyName.startsWith( className ) ) {
+ boolean specialCase = propertyName.length() > className.length() + 2 + redundantString.length()
+ && propertyName.substring( className.length() + 1, className.length() + 1 + redundantString.length() ).equals( redundantString );
+ if ( specialCase ) {
+ //remove id we might be in a @IdClass case
+ return className + propertyName.substring( className.length() + 1 + redundantString.length() );
+ }
}
return null;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdGeneratorResolverSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdGeneratorResolverSecondPass.java
index 4b06c06f69d7..d3528263136e 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdGeneratorResolverSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdGeneratorResolverSecondPass.java
@@ -12,6 +12,7 @@
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.boot.models.JpaAnnotations;
+import org.hibernate.boot.models.annotations.internal.GenericGeneratorAnnotation;
import org.hibernate.boot.models.spi.GenericGeneratorRegistration;
import org.hibernate.boot.models.spi.GlobalRegistrations;
import org.hibernate.boot.models.spi.SequenceGeneratorRegistration;
@@ -351,6 +352,21 @@ protected void handleNamedAutoGenerator() {
}
private boolean handleAsLocalAutoGenerator() {
+ if ( "increment".equals( generatedValue.generator() ) ) {
+ final GenericGeneratorAnnotation incrementGenerator = new GenericGeneratorAnnotation( buildingContext.getBootstrapContext().getModelsContext() );
+ incrementGenerator.name( "increment" );
+ incrementGenerator.strategy( "increment" );
+
+ GeneratorAnnotationHelper.handleGenericGenerator(
+ generatedValue.generator(),
+ incrementGenerator,
+ entityMapping,
+ idValue,
+ buildingContext
+ );
+ return true;
+ }
+
final String generator = generatedValue.generator();
assert !generator.isEmpty();
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/MetadataBuildingProcess.java b/hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/MetadataBuildingProcess.java
index 05d3045ce693..cb590a258b49 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/MetadataBuildingProcess.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/process/spi/MetadataBuildingProcess.java
@@ -69,6 +69,7 @@
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.config.spi.StandardConverters;
import org.hibernate.engine.jdbc.spi.JdbcServices;
+import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.mapping.Table;
import org.hibernate.models.internal.MutableClassDetailsRegistry;
@@ -431,24 +432,28 @@ public static DomainModelSource processManagedResources(
);
final HashSet categorizedClassNames = new HashSet<>();
- allKnownClassNames.forEach( (className) -> applyKnownClass(
- className,
- categorizedClassNames,
- classDetailsRegistry,
- modelCategorizationCollector
- ) );
- xmlPreProcessingResult.getMappedNames().forEach( (className) -> applyKnownClass(
- className,
- categorizedClassNames,
- classDetailsRegistry,
- modelCategorizationCollector
- ) );
+ // apply known classes
+ allKnownClassNames.forEach( (className) -> {
+ if ( categorizedClassNames.add( className ) ) {
+ // not known yet
+ final ClassDetails classDetails = classDetailsRegistry.resolveClassDetails( className );
+ applyKnownClass( classDetails, categorizedClassNames, classDetailsRegistry, modelCategorizationCollector );
+ }
+ } );
+ // apply known "names" - generally this handles dynamic models
+ xmlPreProcessingResult.getMappedNames().forEach( (mappedName) -> {
+ if ( categorizedClassNames.add( mappedName ) ) {
+ // not known yet
+ final ClassDetails classDetails = classDetailsRegistry.resolveClassDetails( mappedName );
+ applyKnownClass( classDetails, categorizedClassNames, classDetailsRegistry, modelCategorizationCollector );
+ }
+ } );
xmlProcessingResult.apply();
return new DomainModelSource(
classDetailsRegistry,
- allKnownClassNames,
+ CollectionHelper.mutableJoin( allKnownClassNames, xmlPreProcessingResult.getMappedNames() ),
modelCategorizationCollector.getGlobalRegistrations(),
rootMappingDefaults,
aggregatedPersistenceUnitMetadata
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/HibernateAnnotations.java b/hibernate-core/src/main/java/org/hibernate/boot/models/HibernateAnnotations.java
index b4ace4402f95..ccba0506939a 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/models/HibernateAnnotations.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/HibernateAnnotations.java
@@ -114,6 +114,10 @@ public interface HibernateAnnotations {
CollectionId.class,
CollectionIdAnnotation.class
);
+ OrmAnnotationDescriptor COLLECTION_ID_JAVA_CLASS = new OrmAnnotationDescriptor<>(
+ CollectionIdJavaClass.class,
+ CollectionIdJavaClassAnnotation.class
+ );
OrmAnnotationDescriptor COLLECTION_ID_JAVA_TYPE = new OrmAnnotationDescriptor<>(
CollectionIdJavaType.class,
CollectionIdJavaTypeAnnotation.class
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/CollectionIdJavaClassAnnotation.java b/hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/CollectionIdJavaClassAnnotation.java
new file mode 100644
index 000000000000..e41dd47200f1
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/CollectionIdJavaClassAnnotation.java
@@ -0,0 +1,53 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.boot.models.annotations.internal;
+
+import org.hibernate.annotations.CollectionIdJavaClass;
+import org.hibernate.models.spi.ModelsContext;
+
+import java.lang.annotation.Annotation;
+import java.util.Map;
+
+/**
+ * @author Steve Ebersole
+ */
+@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
+public class CollectionIdJavaClassAnnotation implements CollectionIdJavaClass {
+ private Class> idType;
+
+ @Override
+ public Class> idType() {
+ return idType;
+ }
+
+ public void idType(Class> idType) {
+ this.idType = idType;
+ }
+
+ @Override
+ public Class extends Annotation> annotationType() {
+ return CollectionIdJavaClass.class;
+ }
+
+ /**
+ * Used in creating dynamic annotation instances (e.g. from XML)
+ */
+ public CollectionIdJavaClassAnnotation(ModelsContext modelContext) {
+ }
+
+ /**
+ * Used in creating annotation instances from JDK variant
+ */
+ public CollectionIdJavaClassAnnotation(CollectionIdJavaClass annotation, ModelsContext modelContext) {
+ this.idType = annotation.idType();
+ }
+
+ /**
+ * Used in creating annotation instances from Jandex variant
+ */
+ public CollectionIdJavaClassAnnotation(Map attributeValues, ModelsContext modelContext) {
+ this.idType = (Class>) attributeValues.get( "idType" );
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/ManyToAnyAnnotation.java b/hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/ManyToAnyAnnotation.java
index df2aebc1c8ce..e9c82de59880 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/ManyToAnyAnnotation.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/ManyToAnyAnnotation.java
@@ -8,11 +8,12 @@
import java.util.Map;
import org.hibernate.annotations.ManyToAny;
+import org.hibernate.boot.models.annotations.spi.AttributeMarker;
import org.hibernate.models.spi.ModelsContext;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
-public class ManyToAnyAnnotation implements ManyToAny {
+public class ManyToAnyAnnotation implements ManyToAny, AttributeMarker, AttributeMarker.Fetchable {
private jakarta.persistence.FetchType fetch;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/internal/ModelsHelper.java b/hibernate-core/src/main/java/org/hibernate/boot/models/internal/ModelsHelper.java
index c1dfe74c1f05..2adfe4d55949 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/models/internal/ModelsHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/internal/ModelsHelper.java
@@ -4,10 +4,14 @@
*/
package org.hibernate.boot.models.internal;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.NClob;
import java.util.function.Supplier;
import org.hibernate.annotations.TenantId;
import org.hibernate.models.internal.MutableClassDetailsRegistry;
+import org.hibernate.models.internal.jdk.JdkClassDetails;
import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.ClassDetailsRegistry;
import org.hibernate.models.spi.RegistryPrimer;
@@ -21,6 +25,18 @@ public class ModelsHelper {
public static void preFillRegistries(RegistryPrimer.Contributions contributions, ModelsContext buildingContext) {
OrmAnnotationHelper.forEachOrmAnnotation( contributions::registerAnnotation );
+ registerPrimitive( boolean.class, buildingContext );
+ registerPrimitive( byte.class, buildingContext );
+ registerPrimitive( short.class, buildingContext );
+ registerPrimitive( int.class, buildingContext );
+ registerPrimitive( long.class, buildingContext );
+ registerPrimitive( double.class, buildingContext );
+ registerPrimitive( float.class, buildingContext );
+ registerPrimitive( char.class, buildingContext );
+ registerPrimitive( Blob.class, buildingContext );
+ registerPrimitive( Clob.class, buildingContext );
+ registerPrimitive( NClob.class, buildingContext );
+
buildingContext.getAnnotationDescriptorRegistry().getDescriptor( TenantId.class );
// if ( buildingContext instanceof JandexModelBuildingContext ) {
@@ -57,6 +73,12 @@ public static void preFillRegistries(RegistryPrimer.Contributions contributions,
// }
}
+ private static void registerPrimitive(Class> theClass, ModelsContext buildingContext) {
+ final MutableClassDetailsRegistry classDetailsRegistry = buildingContext.getClassDetailsRegistry().as( MutableClassDetailsRegistry.class );
+ classDetailsRegistry.addClassDetails( new JdkClassDetails( theClass, buildingContext ) );
+
+ }
+
public static ClassDetails resolveClassDetails(
String className,
ClassDetailsRegistry classDetailsRegistry,
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/UnknownAttributeTypeException.java b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/UnknownAttributeTypeException.java
new file mode 100644
index 000000000000..6c283fd73b97
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/UnknownAttributeTypeException.java
@@ -0,0 +1,18 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.boot.models.xml;
+
+import org.hibernate.HibernateException;
+
+/**
+ * Indicates a problem resolving an attribute's type details - typically with dynamic models.
+ *
+ * @author Steve Ebersole
+ */
+public class UnknownAttributeTypeException extends HibernateException {
+ public UnknownAttributeTypeException(String message) {
+ super( message );
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/DynamicModelHelper.java b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/DynamicModelHelper.java
new file mode 100644
index 000000000000..753db0232c59
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/DynamicModelHelper.java
@@ -0,0 +1,753 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.boot.models.xml.internal;
+
+import jakarta.persistence.TemporalType;
+import org.checkerframework.checker.nullness.qual.NonNull;
+import org.hibernate.HibernateException;
+import org.hibernate.boot.internal.LimitedCollectionClassification;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyMapping;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbAssociationAttribute;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbAttributesContainer;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbAttributesContainerImpl;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbBasicImpl;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbBasicMapping;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbElementCollectionImpl;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddable;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddedIdImpl;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddedMapping;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbEntity;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityImpl;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbManagedType;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclassImpl;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbPluralAttribute;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbTenantIdImpl;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbUserTypeImpl;
+import org.hibernate.boot.models.internal.ModelsHelper;
+import org.hibernate.boot.models.xml.UnknownAttributeTypeException;
+import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
+import org.hibernate.boot.spi.BootstrapContext;
+import org.hibernate.internal.util.StringHelper;
+import org.hibernate.internal.util.collections.CollectionHelper;
+import org.hibernate.models.internal.ClassTypeDetailsImpl;
+import org.hibernate.models.internal.MutableClassDetailsRegistry;
+import org.hibernate.models.internal.ParameterizedTypeDetailsImpl;
+import org.hibernate.models.internal.WildcardTypeDetailsImpl;
+import org.hibernate.models.internal.dynamic.DynamicClassDetails;
+import org.hibernate.models.internal.dynamic.DynamicFieldDetails;
+import org.hibernate.models.internal.jdk.JdkClassDetails;
+import org.hibernate.models.spi.ClassDetails;
+import org.hibernate.models.spi.ClassDetailsRegistry;
+import org.hibernate.models.spi.ModelsContext;
+import org.hibernate.models.spi.MutableClassDetails;
+import org.hibernate.models.spi.TypeDetails;
+import org.hibernate.type.descriptor.java.JavaType;
+import org.hibernate.type.descriptor.jdbc.JdbcType;
+import org.hibernate.usertype.UserType;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.SortedSet;
+
+import static org.hibernate.internal.util.NullnessHelper.nullif;
+import static org.hibernate.internal.util.StringHelper.isNotEmpty;
+import static org.hibernate.models.internal.ModifierUtils.DYNAMIC_ATTRIBUTE_MODIFIERS;
+
+/**
+ * Used from {@linkplain ManagedTypeProcessor} to help dealing with dynamic models
+ *
+ * @author Steve Ebersole
+ */
+public class DynamicModelHelper {
+ /**
+ * Creates DynamicFieldDetails for each attribute defined in the XML
+ */
+ static void prepareDynamicClass(
+ MutableClassDetails classDetails,
+ JaxbManagedType jaxbManagedType,
+ XmlDocumentContext xmlDocumentContext) {
+ if ( jaxbManagedType instanceof JaxbEntityImpl jaxbDynamicEntity ) {
+ final JaxbAttributesContainerImpl attributes = jaxbDynamicEntity.getAttributes();
+
+ if ( attributes != null ) {
+ if ( CollectionHelper.isNotEmpty( attributes.getIdAttributes() ) ) {
+ //
+ attributes.getIdAttributes().forEach( (jaxbId) -> {
+ final TypeDetails attributeJavaType = determineAttributeJavaTypeDetails(
+ jaxbManagedType,
+ jaxbId,
+ xmlDocumentContext
+ );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbId.getName(),
+ attributeJavaType,
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+ }
+ else if ( attributes.getEmbeddedIdAttribute() != null ) {
+ //
+ final JaxbEmbeddedIdImpl embeddedId = attributes.getEmbeddedIdAttribute();
+ final TypeDetails attributeJavaType = determineAttributeJavaTypeDetails(
+ jaxbManagedType,
+ embeddedId,
+ xmlDocumentContext
+ );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ embeddedId.getName(),
+ attributeJavaType,
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ }
+
+ //
+ if ( attributes.getNaturalId() != null ) {
+ attributes.getNaturalId().getBasicAttributes().forEach( (jaxbBasic) -> {
+ final TypeDetails attributeJavaType = determineAttributeJavaTypeDetails(
+ jaxbManagedType,
+ jaxbBasic,
+ xmlDocumentContext
+ );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbBasic.getName(),
+ attributeJavaType,
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+
+ attributes.getNaturalId().getEmbeddedAttributes().forEach( (jaxbEmbedded) -> {
+ final TypeDetails attributeJavaType = determineAttributeJavaTypeDetails(
+ jaxbManagedType,
+ jaxbEmbedded,
+ xmlDocumentContext
+ );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbEmbedded.getName(),
+ attributeJavaType,
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+
+ attributes.getNaturalId().getManyToOneAttributes().forEach( (jaxbManyToOne) -> {
+ final TypeDetails attributeJavaType = determineAttributeJavaTypeDetails(
+ jaxbManyToOne,
+ xmlDocumentContext
+ );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbManyToOne.getName(),
+ attributeJavaType,
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+
+ attributes.getNaturalId().getAnyMappingAttributes().forEach( (jaxbAnyMapping) -> {
+ final TypeDetails attributeJavaType = determineAttributeJavaTypeDetails(
+ jaxbAnyMapping,
+ xmlDocumentContext
+ );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbAnyMapping.getName(),
+ attributeJavaType,
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+ }
+ }
+
+ //
+ final JaxbTenantIdImpl tenantId = jaxbDynamicEntity.getTenantId();
+ if ( tenantId != null ) {
+ final TypeDetails attributeJavaType = determineAttributeJavaTypeDetails(
+ jaxbManagedType,
+ tenantId,
+ xmlDocumentContext
+ );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ tenantId.getName(),
+ attributeJavaType,
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ }
+ }
+ else if ( jaxbManagedType instanceof JaxbMappedSuperclassImpl jaxbMappedSuperclass ) {
+ final JaxbAttributesContainerImpl attributes = jaxbMappedSuperclass.getAttributes();
+
+ if ( attributes != null ) {
+ if ( CollectionHelper.isNotEmpty( attributes.getIdAttributes() ) ) {
+ //
+ attributes.getIdAttributes().forEach( (jaxbId) -> {
+ final TypeDetails attributeJavaType = determineAttributeJavaTypeDetails(
+ jaxbManagedType,
+ jaxbId,
+ xmlDocumentContext
+ );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbId.getName(),
+ attributeJavaType,
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+ }
+ else {
+ //
+ final JaxbEmbeddedIdImpl embeddedId = attributes.getEmbeddedIdAttribute();
+ final TypeDetails attributeJavaType = determineAttributeJavaTypeDetails(
+ jaxbManagedType,
+ embeddedId,
+ xmlDocumentContext
+ );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ embeddedId.getName(),
+ attributeJavaType,
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ }
+ }
+ }
+
+ final JaxbAttributesContainer attributes = jaxbManagedType.getAttributes();
+
+ if ( attributes != null ) {
+ //
+ attributes.getBasicAttributes().forEach( (jaxbBasic) -> {
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbBasic.getName(),
+ determineAttributeJavaTypeDetails( jaxbManagedType, jaxbBasic, xmlDocumentContext ),
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+
+ //
+ attributes.getEmbeddedAttributes().forEach( (jaxbEmbedded) -> {
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbEmbedded.getName(),
+ determineAttributeJavaTypeDetails( jaxbManagedType, jaxbEmbedded, xmlDocumentContext ),
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+
+ //
+ attributes.getOneToOneAttributes().forEach( (jaxbOneToOne) -> {
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbOneToOne.getName(),
+ determineAttributeJavaTypeDetails( jaxbOneToOne, xmlDocumentContext ),
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+
+ //
+ attributes.getManyToOneAttributes().forEach( (jaxbManyToOne) -> {
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbManyToOne.getName(),
+ determineAttributeJavaTypeDetails( jaxbManyToOne, xmlDocumentContext ),
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+
+ //
+ attributes.getAnyMappingAttributes().forEach( (jaxbAnyMapping) -> {
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbAnyMapping.getName(),
+ determineAttributeJavaTypeDetails( jaxbAnyMapping, xmlDocumentContext ),
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ false,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+
+ //
+ attributes.getElementCollectionAttributes().forEach( (jaxbElementCollection) -> {
+ final TypeDetails elementType = determineAttributeJavaTypeDetails( jaxbElementCollection, xmlDocumentContext );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbElementCollection.getName(),
+ makeCollectionType( classDetails, jaxbElementCollection, elementType, xmlDocumentContext ),
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ true,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+
+ //
+ attributes.getOneToManyAttributes().forEach( (jaxbOneToMany) -> {
+ final TypeDetails elementType = determineAttributeJavaTypeDetails( jaxbOneToMany, xmlDocumentContext );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbOneToMany.getName(),
+ // todo : this is wrong. should be the collection-type (List, ...)
+ // wrapping the result from determineAttributeJavaTypeDetails
+ makeCollectionType( classDetails, jaxbOneToMany, elementType, xmlDocumentContext ),
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ true,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+
+ //
+ attributes.getManyToManyAttributes().forEach( (jaxbManyToMany) -> {
+ final TypeDetails elementType = determineAttributeJavaTypeDetails( jaxbManyToMany, xmlDocumentContext );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbManyToMany.getName(),
+ makeCollectionType( classDetails, jaxbManyToMany, elementType, xmlDocumentContext ),
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ true,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+
+ //
+ attributes.getPluralAnyMappingAttributes().forEach( (jaxbPluralAnyMapping) -> {
+ final TypeDetails attributeType = determineAttributeJavaTypeDetails(
+ jaxbPluralAnyMapping,
+ xmlDocumentContext
+ );
+ final DynamicFieldDetails member = new DynamicFieldDetails(
+ jaxbPluralAnyMapping.getName(),
+ attributeType,
+ classDetails,
+ DYNAMIC_ATTRIBUTE_MODIFIERS,
+ false,
+ true,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ classDetails.addField( member );
+ } );
+ }
+ }
+
+ private static ClassDetails COLLECTION_CLASS_DETAILS;
+ private static ClassDetails SET_CLASS_DETAILS;
+ private static ClassDetails LIST_CLASS_DETAILS;
+ private static ClassDetails SORTED_SET_CLASS_DETAILS;
+ private static ClassDetails MAP_CLASS_DETAILS;
+ private static ClassDetails SORTED_MAP_CLASS_DETAILS;
+
+ private static TypeDetails makeCollectionType(
+ ClassDetails declaringType,
+ JaxbPluralAttribute jaxbPluralAttribute,
+ TypeDetails elementType,
+ XmlDocumentContext xmlDocumentContext) {
+ final MutableClassDetailsRegistry classDetailsRegistry = xmlDocumentContext
+ .getBootstrapContext()
+ .getModelsContext()
+ .getClassDetailsRegistry()
+ .as( MutableClassDetailsRegistry.class );
+ final ClassDetails collectionClassDetails;
+ final List typeParams;
+
+ switch ( jaxbPluralAttribute.getClassification() ) {
+ case BAG -> {
+ collectionClassDetails = collectionType( classDetailsRegistry );
+ typeParams = List.of( elementType );
+ }
+ case LIST -> {
+ collectionClassDetails = listType( classDetailsRegistry );
+ typeParams = List.of( elementType );
+ }
+ case SET -> {
+ collectionClassDetails = setType( jaxbPluralAttribute, classDetailsRegistry );
+ typeParams = List.of( elementType );
+ }
+ case MAP -> {
+ collectionClassDetails = mapType( jaxbPluralAttribute, classDetailsRegistry );
+ // for now, just use wildcard for the key
+ final ClassDetails objectClassDetails = classDetailsRegistry.resolveClassDetails( Object.class.getName() );
+ typeParams = List.of(
+ new WildcardTypeDetailsImpl( new ClassTypeDetailsImpl( objectClassDetails, TypeDetails.Kind.CLASS ), true ),
+ elementType
+ );
+ }
+ default -> {
+ throw new UnknownAttributeTypeException(
+ String.format(
+ Locale.ROOT,
+ "Could not determine target type for dynamic attribute [%s, %s]",
+ declaringType,
+ jaxbPluralAttribute.getName()
+ )
+ );
+ }
+ }
+
+ return new ParameterizedTypeDetailsImpl( collectionClassDetails, typeParams, declaringType );
+ }
+
+ private static ClassDetails collectionType(MutableClassDetailsRegistry classDetailsRegistry) {
+ if ( COLLECTION_CLASS_DETAILS == null ) {
+ COLLECTION_CLASS_DETAILS = classDetailsRegistry.getClassDetails( Collection.class.getName() );
+ }
+ return COLLECTION_CLASS_DETAILS;
+ }
+
+ private static ClassDetails listType(MutableClassDetailsRegistry classDetailsRegistry) {
+ if ( LIST_CLASS_DETAILS == null ) {
+ LIST_CLASS_DETAILS = classDetailsRegistry.getClassDetails( List.class.getName() );
+ }
+ return LIST_CLASS_DETAILS;
+ }
+
+ private static ClassDetails setType(JaxbPluralAttribute jaxbPluralAttribute, MutableClassDetailsRegistry classDetailsRegistry) {
+ if ( isSorted( jaxbPluralAttribute ) ) {
+ if ( SORTED_SET_CLASS_DETAILS == null ) {
+ SORTED_SET_CLASS_DETAILS = classDetailsRegistry.getClassDetails( SortedSet.class.getName() );
+ }
+ return SORTED_SET_CLASS_DETAILS;
+ }
+ else {
+ if ( SET_CLASS_DETAILS == null ) {
+ SET_CLASS_DETAILS = classDetailsRegistry.getClassDetails( Set.class.getName() );
+ }
+ return SET_CLASS_DETAILS;
+ }
+ }
+
+ private static boolean isSorted(JaxbPluralAttribute jaxbPluralAttribute) {
+ return StringHelper.isNotEmpty( jaxbPluralAttribute.getSort() )
+ || jaxbPluralAttribute.getSortNatural() != null
+ || StringHelper.isNotEmpty( jaxbPluralAttribute.getOrderBy() );
+ }
+
+ private static ClassDetails mapType(JaxbPluralAttribute jaxbPluralAttribute, MutableClassDetailsRegistry classDetailsRegistry) {
+ if ( isSorted( jaxbPluralAttribute ) ) {
+ if ( SORTED_MAP_CLASS_DETAILS == null ) {
+ SORTED_MAP_CLASS_DETAILS = classDetailsRegistry.getClassDetails( SortedMap.class.getName() );
+ }
+ return SORTED_MAP_CLASS_DETAILS;
+ }
+ else {
+ if ( MAP_CLASS_DETAILS == null ) {
+ MAP_CLASS_DETAILS = classDetailsRegistry.getClassDetails( Map.class.getName() );
+ }
+ return MAP_CLASS_DETAILS;
+ }
+ }
+
+ /**
+ * Determine the appropriate "Java type" for the given basic mapping.
+ * Wraps the result of {@linkplain #determineAttributeJavaType} in a {@linkplain ClassTypeDetailsImpl}
+ * Handles {@code }, {@code }, {@code }.
+ */
+ private static TypeDetails determineAttributeJavaTypeDetails(
+ JaxbManagedType declaringType,
+ JaxbBasicMapping jaxbBasicMapping,
+ XmlDocumentContext xmlDocumentContext) {
+ return new ClassTypeDetailsImpl( determineAttributeJavaType( declaringType, jaxbBasicMapping, xmlDocumentContext ), TypeDetails.Kind.CLASS );
+ }
+
+ private static ClassDetails determineAttributeJavaType(
+ JaxbManagedType declaringType,
+ JaxbBasicMapping jaxbBasicMapping,
+ XmlDocumentContext xmlDocumentContext) {
+ // explicit
+ final String target = jaxbBasicMapping.getTarget();
+ if ( isNotEmpty( target ) ) {
+ final SimpleTypeInterpretation simpleTypeInterpretation = SimpleTypeInterpretation.interpret( target );
+ if ( simpleTypeInterpretation == null ) {
+ throw new UnknownAttributeTypeException(
+ String.format(
+ Locale.ROOT,
+ "Could not determine target type for dynamic attribute [%s, %s]",
+ declaringType,
+ jaxbBasicMapping.getName()
+ )
+ );
+ }
+ return resolveBasicMappingTarget( simpleTypeInterpretation, xmlDocumentContext );
+ }
+
+ final BootstrapContext bootstrapContext = xmlDocumentContext.getBootstrapContext();
+ final ModelsContext modelsContext = bootstrapContext.getModelsContext();
+
+ // UserType
+ final JaxbUserTypeImpl userTypeNode = jaxbBasicMapping.getType();
+ if ( userTypeNode != null ) {
+ final String userTypeImplName = userTypeNode.getValue();
+ if ( isNotEmpty( userTypeImplName ) ) {
+ final ClassDetails userTypeImplDetails = xmlDocumentContext.resolveJavaType( userTypeImplName );
+ // safe to convert to class, though unfortunate to have to instantiate it...
+ final UserType> userType = createInstance( userTypeImplDetails );
+ final Class> modelClass = userType.returnedClass();
+ return modelsContext.getClassDetailsRegistry().getClassDetails( modelClass.getName() );
+ }
+ }
+
+ // JavaType
+ final String javaTypeImplName = jaxbBasicMapping.getJavaType();
+ if ( isNotEmpty( javaTypeImplName ) ) {
+ final ClassDetails javaTypeImplDetails = xmlDocumentContext.resolveJavaType( javaTypeImplName );
+ // safe to convert to class, though unfortunate to have to instantiate it...
+ final JavaType> javaType = createInstance( javaTypeImplDetails );
+ final Class> modelClass = javaType.getJavaTypeClass();
+ return modelsContext.getClassDetailsRegistry().getClassDetails( modelClass.getName() );
+ }
+
+ // JdbcType
+ final String jdbcTypeImplName = jaxbBasicMapping.getJdbcType();
+ final Integer jdbcTypeCode = jaxbBasicMapping.getJdbcTypeCode();
+ final JdbcType jdbcType;
+ if ( isNotEmpty( jdbcTypeImplName ) ) {
+ final ClassDetails jdbcTypeImplDetails = xmlDocumentContext.resolveJavaType( javaTypeImplName );
+ jdbcType = createInstance( jdbcTypeImplDetails );
+ }
+ else if ( jdbcTypeCode != null ) {
+ jdbcType = bootstrapContext.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( jdbcTypeCode );
+ }
+ else {
+ jdbcType = null;
+ }
+ if ( jdbcType != null ) {
+ final JavaType> javaType = jdbcType.getJdbcRecommendedJavaTypeMapping( 0, 0, bootstrapContext.getTypeConfiguration() );
+ final Class> modelClass = javaType.getJavaTypeClass();
+ return modelsContext.getClassDetailsRegistry().getClassDetails( modelClass.getName() );
+ }
+
+ if ( jaxbBasicMapping instanceof JaxbBasicImpl jaxbBasicAttribute ) {
+ final TemporalType temporalType = jaxbBasicAttribute.getTemporal();
+ if ( temporalType != null ) {
+ return resolveTemporalJavaType( temporalType, xmlDocumentContext );
+ }
+ }
+
+ final String declaringTypeName;
+ if ( declaringType instanceof JaxbEntity jaxbEntity ) {
+ declaringTypeName = StringHelper.nullIfEmpty( jaxbEntity.getName() );
+ }
+ else if ( declaringType instanceof JaxbEmbeddable jaxbEmbeddable ) {
+ declaringTypeName = StringHelper.nullIfEmpty( jaxbEmbeddable.getName() );
+ }
+ else {
+ declaringTypeName = null;
+ }
+
+ throw new UnknownAttributeTypeException(
+ String.format(
+ Locale.ROOT,
+ "Could not determine target type for dynamic attribute [%s#%s]",
+ declaringTypeName != null ? declaringTypeName : declaringType.getClazz(),
+ jaxbBasicMapping.getName()
+ )
+ );
+ }
+
+ /**
+ * Conceptually very similar to {@linkplain SimpleTypeInterpretation}, but here the distinction between
+ * primitive and wrapper ({@code boolean} and {@code Boolean} e.g.) is important while in
+ * SimpleTypeInterpretation we only care about the wrapper.
+ */
+ private static ClassDetails resolveBasicMappingTarget(SimpleTypeInterpretation targetInterpretation, XmlDocumentContext xmlDocumentContext) {
+ final ModelsContext modelsContext = xmlDocumentContext.getBootstrapContext().getModelsContext();
+ final ClassDetailsRegistry classDetailsRegistry = modelsContext.getClassDetailsRegistry();
+ return classDetailsRegistry.resolveClassDetails( targetInterpretation.getJavaType().getName() );
+ }
+
+ private static MutableClassDetails resolveTemporalJavaType(
+ TemporalType temporalType,
+ XmlDocumentContext xmlDocumentContext) {
+ final ModelsContext modelsContext = xmlDocumentContext.getBootstrapContext().getModelsContext();
+ final MutableClassDetailsRegistry classDetailsRegistry = modelsContext.getClassDetailsRegistry().as( MutableClassDetailsRegistry.class );
+ switch ( temporalType ) {
+ case DATE -> {
+ return (MutableClassDetails) classDetailsRegistry.resolveClassDetails(
+ java.sql.Date.class.getName(),
+ name -> new JdkClassDetails( java.sql.Date.class, modelsContext )
+ );
+ }
+ case TIME -> {
+ return (MutableClassDetails) classDetailsRegistry.resolveClassDetails(
+ java.sql.Time.class.getName(),
+ name -> new JdkClassDetails( java.sql.Time.class, modelsContext )
+ );
+ }
+ default -> {
+ return (MutableClassDetails) classDetailsRegistry.resolveClassDetails(
+ java.sql.Timestamp.class.getName(),
+ name -> new JdkClassDetails( java.sql.Timestamp.class, modelsContext )
+ );
+ }
+ }
+ }
+
+ /**
+ * Determine the appropriate TypeDetails for the given embedded mapping.
+ * Handles {@code }, {@code }
+ */
+ private static TypeDetails determineAttributeJavaTypeDetails(
+ JaxbManagedType declaringType,
+ JaxbEmbeddedMapping jaxbEmbeddedMapping,
+ XmlDocumentContext xmlDocumentContext) {
+ final String target = jaxbEmbeddedMapping.getTarget();
+ if ( isNotEmpty( target ) ) {
+ final ModelsContext modelsContext = xmlDocumentContext.getBootstrapContext().getModelsContext();
+ final ClassDetails memberTypeClassDetails = ModelsHelper.resolveClassDetails(
+ target,
+ modelsContext.getClassDetailsRegistry(),
+ () -> new DynamicClassDetails( target, modelsContext )
+ );
+
+ return new ClassTypeDetailsImpl( memberTypeClassDetails, TypeDetails.Kind.CLASS );
+ }
+
+ // todo : need more context here for better exception message
+ throw new HibernateException( "Could not determine target type for dynamic attribute" );
+ }
+
+ /**
+ * Determine the appropriate TypeDetails for the given association mapping.
+ * Handles {@code }, {@code }, {@code }, {@code }
+ */
+ private static TypeDetails determineAttributeJavaTypeDetails(
+ JaxbAssociationAttribute jaxbAssociationAttribute,
+ XmlDocumentContext xmlDocumentContext) {
+ final String target = jaxbAssociationAttribute.getTargetEntity();
+ if ( isNotEmpty( target ) ) {
+ final ModelsContext modelsContext = xmlDocumentContext.getBootstrapContext().getModelsContext();
+ final ClassDetails classDetails = ModelsHelper.resolveClassDetails(
+ target,
+ modelsContext.getClassDetailsRegistry(),
+ () -> new DynamicClassDetails(
+ target,
+ null,
+ false,
+ null,
+ null,
+ modelsContext
+ )
+ );
+ return new ClassTypeDetailsImpl( classDetails, TypeDetails.Kind.CLASS );
+ }
+
+ // todo : need more context here for better exception message
+ throw new HibernateException( "Could not determine target type for dynamic attribute" );
+ }
+
+ /**
+ * Determine the appropriate TypeDetails for the given ANY mapping.
+ * Handles {@code }, {@code }.
+ */
+ private static TypeDetails determineAttributeJavaTypeDetails(
+ JaxbAnyMapping jaxbAnyMapping,
+ XmlDocumentContext xmlDocumentContext) {
+ // Logically this is Object, which is what we return here for now.
+ // todo : might be nice to allow specifying a "common interface"
+ final ModelsContext modelsContext = xmlDocumentContext.getBootstrapContext().getModelsContext();
+ final ClassDetails objectClassDetails = modelsContext.getClassDetailsRegistry().resolveClassDetails( Object.class.getName() );
+ return new ClassTypeDetailsImpl( objectClassDetails, TypeDetails.Kind.CLASS );
+ }
+
+ /**
+ * Determine the appropriate TypeDetails for the given ANY mapping.
+ * Handles {@code }.
+ */
+ private static TypeDetails determineAttributeJavaTypeDetails(
+ JaxbElementCollectionImpl jaxbElementCollection,
+ XmlDocumentContext xmlDocumentContext) {
+ final LimitedCollectionClassification classification = nullif( jaxbElementCollection.getClassification(), LimitedCollectionClassification.BAG );
+ return switch ( classification ) {
+ case BAG -> resolveCollectionType( Collection.class, xmlDocumentContext );
+ case LIST -> resolveCollectionType( List.class, xmlDocumentContext );
+ case SET -> resolveCollectionType( Set.class, xmlDocumentContext );
+ case MAP -> resolveCollectionType( Map.class, xmlDocumentContext );
+ };
+ }
+
+ private static TypeDetails resolveCollectionType(Class> collectionType, XmlDocumentContext xmlDocumentContext) {
+ final ClassDetails classDetails = xmlDocumentContext
+ .getBootstrapContext()
+ .getModelsContext()
+ .getClassDetailsRegistry()
+ .resolveClassDetails( collectionType.getName() );
+ return new ClassTypeDetailsImpl( classDetails, TypeDetails.Kind.CLASS );
+ }
+
+ @NonNull
+ private static T createInstance(ClassDetails classDetails) {
+ try {
+ //noinspection unchecked
+ return (T) classDetails.toJavaClass().getConstructor().newInstance();
+ }
+ catch (Exception e) {
+ throw new HibernateException( "Unable to create instance from incoming ClassDetails - " + classDetails );
+ }
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/ManagedTypeProcessor.java b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/ManagedTypeProcessor.java
index 6be50ea2a051..122f7b5973dc 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/ManagedTypeProcessor.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/ManagedTypeProcessor.java
@@ -9,7 +9,6 @@
import org.hibernate.MappingException;
import org.hibernate.annotations.CacheConcurrencyStrategy;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbAttributesContainer;
import org.hibernate.boot.jaxb.mapping.spi.JaxbAttributesContainerImpl;
import org.hibernate.boot.jaxb.mapping.spi.JaxbCachingImpl;
import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddableImpl;
@@ -18,7 +17,6 @@
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityOrMappedSuperclass;
import org.hibernate.boot.jaxb.mapping.spi.JaxbIdImpl;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbManagedType;
import org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclassImpl;
import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistentAttribute;
import org.hibernate.boot.jaxb.mapping.spi.JaxbTenantIdImpl;
@@ -42,9 +40,7 @@
import org.hibernate.models.ModelsException;
import org.hibernate.models.internal.ClassTypeDetailsImpl;
import org.hibernate.models.internal.ModelsClassLogging;
-import org.hibernate.models.internal.ModifierUtils;
import org.hibernate.models.internal.dynamic.DynamicClassDetails;
-import org.hibernate.models.internal.dynamic.DynamicFieldDetails;
import org.hibernate.models.rendering.internal.RenderingTargetCollectingImpl;
import org.hibernate.models.rendering.internal.SimpleRenderer;
import org.hibernate.models.spi.ClassDetails;
@@ -74,7 +70,6 @@
* @author Steve Ebersole
*/
public class ManagedTypeProcessor {
- private static final int MEMBER_MODIFIERS = ModifierUtils.DYNAMIC_ATTRIBUTE_MODIFIERS;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Entity
@@ -102,18 +97,33 @@ public static void processCompleteEntity(
classDetails = (MutableClassDetails) ModelsHelper.resolveClassDetails(
jaxbEntity.getName(),
classDetailsRegistry,
- () ->
- new DynamicClassDetails(
- jaxbEntity.getName(),
- null,
- false,
- null,
- null,
- xmlDocumentContext.getModelBuildingContext()
- )
+ () -> {
+ final ClassDetails superClass;
+ final TypeDetails superType;
+
+ if ( StringHelper.isEmpty( jaxbEntity.getExtends() ) ) {
+ superClass = null;
+ superType = null;
+ }
+ else {
+ // we expect the super to have been processed first.
+ // not worth the effort to support the delay
+ superClass = classDetailsRegistry.getClassDetails( jaxbEntity.getExtends() );
+ superType = new ClassTypeDetailsImpl( superClass, TypeDetails.Kind.CLASS );
+ }
+
+ return new DynamicClassDetails(
+ jaxbEntity.getName(),
+ null,
+ jaxbEntity.isAbstract() != null && jaxbEntity.isAbstract(),
+ superClass,
+ superType,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ }
);
- prepareDynamicClass( classDetails, jaxbEntity, xmlDocumentContext );
+ DynamicModelHelper.prepareDynamicClass( classDetails, jaxbEntity, xmlDocumentContext );
}
else {
memberAdjuster = ManagedTypeProcessor::adjustCompleteNonDynamicTypeMember;
@@ -165,332 +175,6 @@ private static AccessType defaultAccessTypeFromDefaultAccessor(XmlDocumentContex
return null;
}
- /**
- * Creates fake FieldDetails for each attribute defined in the XML
- */
- private static void prepareDynamicClass(
- MutableClassDetails classDetails,
- JaxbManagedType jaxbManagedType,
- XmlDocumentContext xmlDocumentContext) {
- if ( jaxbManagedType instanceof JaxbEntityImpl jaxbDynamicEntity ) {
- final JaxbAttributesContainerImpl attributes = jaxbDynamicEntity.getAttributes();
-
- if ( attributes != null ) {
- if ( CollectionHelper.isNotEmpty( attributes.getIdAttributes() ) ) {
- //
- attributes.getIdAttributes().forEach( (jaxbId) -> {
- final TypeDetails attributeJavaType = determineDynamicAttributeJavaType(
- jaxbId,
- xmlDocumentContext
- );
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbId.getName(),
- attributeJavaType,
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
- }
- else if ( attributes.getEmbeddedIdAttribute() != null ) {
- //
- final JaxbEmbeddedIdImpl embeddedId = attributes.getEmbeddedIdAttribute();
- final TypeDetails attributeJavaType = determineDynamicAttributeJavaType(
- embeddedId,
- xmlDocumentContext
- );
- final DynamicFieldDetails member = new DynamicFieldDetails(
- embeddedId.getName(),
- attributeJavaType,
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- }
-
- //
- if ( attributes.getNaturalId() != null ) {
- attributes.getNaturalId().getBasicAttributes().forEach( (jaxbBasic) -> {
- final TypeDetails attributeJavaType = determineDynamicAttributeJavaType(
- jaxbBasic,
- xmlDocumentContext
- );
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbBasic.getName(),
- attributeJavaType,
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
-
- attributes.getNaturalId().getEmbeddedAttributes().forEach( (jaxbEmbedded) -> {
- final TypeDetails attributeJavaType = determineDynamicAttributeJavaType(
- jaxbEmbedded,
- xmlDocumentContext
- );
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbEmbedded.getName(),
- attributeJavaType,
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
-
- attributes.getNaturalId().getManyToOneAttributes().forEach( (jaxbManyToOne) -> {
- final TypeDetails attributeJavaType = determineDynamicAttributeJavaType(
- jaxbManyToOne,
- xmlDocumentContext
- );
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbManyToOne.getName(),
- attributeJavaType,
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
-
- attributes.getNaturalId().getAnyMappingAttributes().forEach( (jaxbAnyMapping) -> {
- final TypeDetails attributeJavaType = determineDynamicAttributeJavaType(
- jaxbAnyMapping,
- xmlDocumentContext
- );
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbAnyMapping.getName(),
- attributeJavaType,
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
- }
- }
-
- //
- final JaxbTenantIdImpl tenantId = jaxbDynamicEntity.getTenantId();
- if ( tenantId != null ) {
- final TypeDetails attributeJavaType = determineDynamicAttributeJavaType(
- tenantId,
- xmlDocumentContext
- );
- final DynamicFieldDetails member = new DynamicFieldDetails(
- tenantId.getName(),
- attributeJavaType,
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- }
- }
- else if ( jaxbManagedType instanceof JaxbMappedSuperclassImpl jaxbMappedSuperclass ) {
- final JaxbAttributesContainerImpl attributes = jaxbMappedSuperclass.getAttributes();
-
- if ( attributes != null ) {
- if ( CollectionHelper.isNotEmpty( attributes.getIdAttributes() ) ) {
- //
- attributes.getIdAttributes().forEach( (jaxbId) -> {
- final TypeDetails attributeJavaType = determineDynamicAttributeJavaType(
- jaxbId,
- xmlDocumentContext
- );
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbId.getName(),
- attributeJavaType,
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
- }
- else {
- //
- final JaxbEmbeddedIdImpl embeddedId = attributes.getEmbeddedIdAttribute();
- final TypeDetails attributeJavaType = determineDynamicAttributeJavaType(
- embeddedId,
- xmlDocumentContext
- );
- final DynamicFieldDetails member = new DynamicFieldDetails(
- embeddedId.getName(),
- attributeJavaType,
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- }
- }
- }
-
- final JaxbAttributesContainer attributes = jaxbManagedType.getAttributes();
-
- if ( attributes != null ) {
- //
- attributes.getBasicAttributes().forEach( (jaxbBasic) -> {
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbBasic.getName(),
- determineDynamicAttributeJavaType( jaxbBasic, xmlDocumentContext ),
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
-
- //
- attributes.getEmbeddedAttributes().forEach( (jaxbEmbedded) -> {
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbEmbedded.getName(),
- determineDynamicAttributeJavaType( jaxbEmbedded, xmlDocumentContext ),
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
-
- //
- attributes.getOneToOneAttributes().forEach( (jaxbOneToOne) -> {
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbOneToOne.getName(),
- determineDynamicAttributeJavaType( jaxbOneToOne, xmlDocumentContext ),
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
-
- //
- attributes.getManyToOneAttributes().forEach( (jaxbManyToOne) -> {
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbManyToOne.getName(),
- determineDynamicAttributeJavaType( jaxbManyToOne, xmlDocumentContext ),
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
-
- //
- attributes.getAnyMappingAttributes().forEach( (jaxbAnyMapping) -> {
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbAnyMapping.getName(),
- determineDynamicAttributeJavaType( jaxbAnyMapping, xmlDocumentContext ),
- classDetails,
- MEMBER_MODIFIERS,
- false,
- false,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
-
- //
- attributes.getElementCollectionAttributes().forEach( (jaxbElementCollection) -> {
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbElementCollection.getName(),
- determineDynamicAttributeJavaType( jaxbElementCollection, xmlDocumentContext ),
- classDetails,
- MEMBER_MODIFIERS,
- false,
- true,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
-
- //
- attributes.getOneToManyAttributes().forEach( (jaxbOneToMany) -> {
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbOneToMany.getName(),
- determineDynamicAttributeJavaType( jaxbOneToMany, xmlDocumentContext ),
- classDetails,
- MEMBER_MODIFIERS,
- false,
- true,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
-
- //
- attributes.getManyToManyAttributes().forEach( (jaxbManyToMany) -> {
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbManyToMany.getName(),
- determineDynamicAttributeJavaType( jaxbManyToMany, xmlDocumentContext ),
- classDetails,
- MEMBER_MODIFIERS,
- false,
- true,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
-
- //
- attributes.getPluralAnyMappingAttributes().forEach( (jaxbPluralAnyMapping) -> {
- final TypeDetails attributeType = determineDynamicAttributeJavaType(
- jaxbPluralAnyMapping,
- xmlDocumentContext
- );
- final DynamicFieldDetails member = new DynamicFieldDetails(
- jaxbPluralAnyMapping.getName(),
- attributeType,
- classDetails,
- MEMBER_MODIFIERS,
- false,
- true,
- xmlDocumentContext.getModelBuildingContext()
- );
- classDetails.addField( member );
- } );
- }
- }
-
- private static TypeDetails determineDynamicAttributeJavaType(
- JaxbPersistentAttribute jaxbPersistentAttribute,
- XmlDocumentContext xmlDocumentContext) {
- final MutableClassDetails classDetails = xmlDocumentContext.resolveDynamicJavaType( jaxbPersistentAttribute );
- return new ClassTypeDetailsImpl( classDetails, TypeDetails.Kind.CLASS );
- }
-
private static void adjustDynamicTypeMember(
MutableMemberDetails memberDetails,
JaxbPersistentAttribute jaxbAttribute,
@@ -628,8 +312,8 @@ private static void renderClass(MutableClassDetails classDetails, XmlDocumentCon
final RenderingTargetCollectingImpl collectingTarget = new RenderingTargetCollectingImpl();
final SimpleRenderer renderer = new SimpleRenderer( collectingTarget );
- renderer.renderClass( classDetails, xmlDocumentContext.getModelBuildingContext() );
- XML_PROCESS_LOGGER.debugf( "Class annotations from XML for %s:\n%s", classDetails.getName(), renderer.toString() );
+ renderer.renderClass( classDetails, xmlDocumentContext.getModelBuildingContext() );
+ XML_PROCESS_LOGGER.debugf( "Class annotations from XML for %s:\n%s", classDetails.getName(), collectingTarget.toString() );
}
private static void applyAccessAnnotation(
@@ -955,7 +639,7 @@ public static void processCompleteEmbeddable(
classAccessType = AccessType.FIELD;
memberAdjuster = ManagedTypeProcessor::adjustDynamicTypeMember;
- prepareDynamicClass( classDetails, jaxbEmbeddable, xmlDocumentContext );
+ DynamicModelHelper.prepareDynamicClass( classDetails, jaxbEmbeddable, xmlDocumentContext );
}
else {
final String className = XmlProcessingHelper.determineClassName( jaxbRoot, jaxbEmbeddable );
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/SimpleTypeInterpretation.java b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/SimpleTypeInterpretation.java
index 9193ecdb4a41..5bceead6b732 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/SimpleTypeInterpretation.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/SimpleTypeInterpretation.java
@@ -4,9 +4,12 @@
*/
package org.hibernate.boot.models.xml.internal;
+import org.hibernate.internal.util.StringHelper;
+
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.InetAddress;
+import java.net.URL;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Date;
@@ -31,307 +34,296 @@
import java.util.TimeZone;
import java.util.UUID;
-import org.hibernate.internal.util.StringHelper;
-import org.hibernate.type.descriptor.java.BasicJavaType;
-import org.hibernate.type.descriptor.java.BigDecimalJavaType;
-import org.hibernate.type.descriptor.java.BigIntegerJavaType;
-import org.hibernate.type.descriptor.java.BlobJavaType;
-import org.hibernate.type.descriptor.java.BooleanJavaType;
-import org.hibernate.type.descriptor.java.ByteJavaType;
-import org.hibernate.type.descriptor.java.CalendarJavaType;
-import org.hibernate.type.descriptor.java.CharacterJavaType;
-import org.hibernate.type.descriptor.java.ClassJavaType;
-import org.hibernate.type.descriptor.java.ClobJavaType;
-import org.hibernate.type.descriptor.java.CurrencyJavaType;
-import org.hibernate.type.descriptor.java.DoubleJavaType;
-import org.hibernate.type.descriptor.java.DurationJavaType;
-import org.hibernate.type.descriptor.java.FloatJavaType;
-import org.hibernate.type.descriptor.java.InetAddressJavaType;
-import org.hibernate.type.descriptor.java.InstantJavaType;
-import org.hibernate.type.descriptor.java.IntegerJavaType;
-import org.hibernate.type.descriptor.java.JdbcDateJavaType;
-import org.hibernate.type.descriptor.java.JdbcTimeJavaType;
-import org.hibernate.type.descriptor.java.JdbcTimestampJavaType;
-import org.hibernate.type.descriptor.java.LocalDateJavaType;
-import org.hibernate.type.descriptor.java.LocalDateTimeJavaType;
-import org.hibernate.type.descriptor.java.LocalTimeJavaType;
-import org.hibernate.type.descriptor.java.LocaleJavaType;
-import org.hibernate.type.descriptor.java.LongJavaType;
-import org.hibernate.type.descriptor.java.NClobJavaType;
-import org.hibernate.type.descriptor.java.OffsetDateTimeJavaType;
-import org.hibernate.type.descriptor.java.OffsetTimeJavaType;
-import org.hibernate.type.descriptor.java.ShortJavaType;
-import org.hibernate.type.descriptor.java.StringJavaType;
-import org.hibernate.type.descriptor.java.TimeZoneJavaType;
-import org.hibernate.type.descriptor.java.UUIDJavaType;
-import org.hibernate.type.descriptor.java.UrlJavaType;
-import org.hibernate.type.descriptor.java.YearJavaType;
-import org.hibernate.type.descriptor.java.ZoneIdJavaType;
-import org.hibernate.type.descriptor.java.ZoneOffsetJavaType;
-import org.hibernate.type.descriptor.java.ZonedDateTimeJavaType;
-
/**
* @author Steve Ebersole
*/
public enum SimpleTypeInterpretation {
- BOOLEAN( Boolean.class, BooleanJavaType.class ),
- BYTE( Byte.class, ByteJavaType.class ),
- SHORT( Short.class, ShortJavaType.class ),
- INTEGER( Integer.class, IntegerJavaType.class ),
- LONG( Long.class, LongJavaType.class ),
- DOUBLE( Double.class, DoubleJavaType.class ),
- FLOAT( Float.class, FloatJavaType.class ),
- BIG_INTEGER( BigInteger.class, BigIntegerJavaType.class ),
- BIG_DECIMAL( BigDecimal.class, BigDecimalJavaType.class ),
- CHARACTER( Character.class, CharacterJavaType.class ),
- STRING( String.class, StringJavaType.class ),
- INSTANT( Instant.class, InstantJavaType.class ),
- DURATION( Duration.class, DurationJavaType.class ),
- YEAR( Year.class, YearJavaType.class ),
- LOCAL_DATE_TIME( LocalDateTime.class, LocalDateTimeJavaType.class ),
- LOCAL_DATE( LocalDate.class, LocalDateJavaType.class ),
- LOCAL_TIME( LocalTime.class, LocalTimeJavaType.class ),
- OFFSET_DATE_TIME( OffsetDateTime.class, OffsetDateTimeJavaType.class ),
- OFFSET_TIME( OffsetTime.class, OffsetTimeJavaType.class ),
- ZONED_DATE_TIME( ZonedDateTime.class, ZonedDateTimeJavaType.class ),
- ZONE_ID( ZoneId.class, ZoneIdJavaType.class ),
- ZONE_OFFSET( ZoneOffset.class, ZoneOffsetJavaType.class ),
- UUID( UUID .class, UUIDJavaType.class ),
- URL( java.net.URL.class, UrlJavaType.class ),
- INET_ADDRESS( InetAddress.class, InetAddressJavaType.class ),
- CURRENCY( Currency.class, CurrencyJavaType.class ),
- LOCALE( Locale.class, LocaleJavaType.class ),
- CLASS( Class.class, ClassJavaType.class ),
- BLOB( Blob.class, BlobJavaType.class ),
- CLOB( Clob.class, ClobJavaType.class ),
- NCLOB( NClob.class, NClobJavaType.class ),
- JDBC_TIMESTAMP( Timestamp.class, JdbcTimestampJavaType.class ),
- JDBC_DATE( Date.class, JdbcDateJavaType.class ),
- JDBC_TIME( Time.class, JdbcTimeJavaType.class ),
- CALENDAR( Calendar.class, CalendarJavaType.class ),
- TIME_ZONE( TimeZone.class, TimeZoneJavaType.class )
+ BOOLEAN( Boolean.class ),
+ BYTE( Byte.class ),
+ SHORT( Short.class ),
+ INTEGER( Integer.class ),
+ LONG( Long.class ),
+ DOUBLE( Double.class ),
+ FLOAT( Float.class ),
+ BIG_INTEGER( BigInteger.class ),
+ BIG_DECIMAL( BigDecimal.class ),
+ CHARACTER( Character.class ),
+ STRING( String.class ),
+ INSTANT( Instant.class ),
+ DURATION( Duration.class ),
+ YEAR( Year.class ),
+ LOCAL_DATE_TIME( LocalDateTime.class ),
+ LOCAL_DATE( LocalDate.class ),
+ LOCAL_TIME( LocalTime.class ),
+ OFFSET_DATE_TIME( OffsetDateTime.class ),
+ OFFSET_TIME( OffsetTime.class ),
+ ZONED_DATE_TIME( ZonedDateTime.class ),
+ ZONE_ID( ZoneId.class ),
+ ZONE_OFFSET( ZoneOffset.class ),
+ UUID( UUID .class ),
+ URL( java.net.URL.class ),
+ INET_ADDRESS( InetAddress.class ),
+ CURRENCY( Currency.class ),
+ LOCALE( Locale.class ),
+ CLASS( Class.class ),
+ BLOB( Blob.class ),
+ CLOB( Clob.class ),
+ NCLOB( NClob.class ),
+ JDBC_TIMESTAMP( Timestamp.class ),
+ JDBC_DATE( Date.class ),
+ JDBC_TIME( Time.class ),
+ CALENDAR( Calendar.class ),
+ TIME_ZONE( TimeZone.class ),
+
+ PRIMITIVE_BOOLEAN( boolean.class, BOOLEAN ),
+ PRIMITIVE_BYTE( byte.class, BYTE ),
+ PRIMITIVE_SHORT( short.class, SHORT ),
+ PRIMITIVE_INTEGER( int.class, INTEGER ),
+ PRIMITIVE_LONG( long.class, LONG ),
+ PRIMITIVE_DOUBLE( double.class, DOUBLE ),
+ PRIMITIVE_FLOAT( float.class, FLOAT ),
+ PRIMITIVE_CHARACTER( char.class, CHARACTER ),
;
- SimpleTypeInterpretation(Class> javaType, Class extends BasicJavaType>> javaTypeDescriptorType) {
+
+ private final Class> javaType;
+ private final SimpleTypeInterpretation objectForm;
+
+ SimpleTypeInterpretation(Class> javaType) {
this.javaType = javaType;
- this.javaTypeDescriptorType = javaTypeDescriptorType;
+ this.objectForm = this;
}
- private final Class> javaType;
- private final Class extends BasicJavaType>> javaTypeDescriptorType;
+ SimpleTypeInterpretation(Class> javaType, SimpleTypeInterpretation objectForm) {
+ this.javaType = javaType;
+ this.objectForm = objectForm;
+ }
public Class> getJavaType() {
return javaType;
}
- public Class extends BasicJavaType>> getJavaTypeDescriptorType() {
- return javaTypeDescriptorType;
+ public SimpleTypeInterpretation getObjectForm() {
+ return objectForm;
}
public static SimpleTypeInterpretation interpret(String name) {
assert StringHelper.isNotEmpty( name );
+ if ( boolean.class.getName().equals( name ) ) {
+ return PRIMITIVE_BOOLEAN;
+ }
+
+ if ( byte.class.getName().equals( name ) ) {
+ return PRIMITIVE_BYTE;
+ }
+
+ if ( short.class.getName().equals( name ) ) {
+ return PRIMITIVE_SHORT;
+ }
+
+ if ( int.class.getName().equals( name ) ) {
+ return PRIMITIVE_INTEGER;
+ }
+
+ if ( long.class.getName().equals( name ) ) {
+ return PRIMITIVE_LONG;
+ }
+
+ if ( double.class.getName().equals( name ) ) {
+ return PRIMITIVE_DOUBLE;
+ }
+
+ if ( float.class.getName().equals( name ) ) {
+ return PRIMITIVE_FLOAT;
+ }
+
+ if ( char.class.getName().equals( name ) ) {
+ return PRIMITIVE_CHARACTER;
+ }
- if ( name.equalsIgnoreCase( "boolean" )
- || Boolean.class.getName().equals( name ) ) {
+ if ( Boolean.class.getName().equals( name )
+ || Boolean.class.getSimpleName().equals( name ) ) {
return BOOLEAN;
}
- if ( name.equalsIgnoreCase( "byte" )
- || Byte.class.getName().equals( name ) ) {
+ if ( Byte.class.getName().equals( name )
+ || Byte.class.getSimpleName().equals( name ) ) {
return BYTE;
}
- if ( name.equalsIgnoreCase( "short" )
- || Short.class.getName().equals( name ) ) {
+ if ( Short.class.getName().equals( name )
+ || Short.class.getSimpleName().equals( name ) ) {
return SHORT;
}
- if ( name.equalsIgnoreCase( "int" )
- || name.equalsIgnoreCase( "integer" )
- || Integer.class.getName().equals( name ) ) {
+ if ( Integer.class.getName().equals( name )
+ || Integer.class.getSimpleName().equals( name ) ) {
return INTEGER;
}
- if ( name.equalsIgnoreCase( "long" )
- || Long.class.getName().equals( name ) ) {
+ if ( Long.class.getName().equals( name )
+ || Long.class.getSimpleName().equals( name ) ) {
return LONG;
}
- if ( name.equalsIgnoreCase( "double" )
- || Double.class.getName().equals( name ) ) {
+ if ( Double.class.getName().equals( name )
+ || Double.class.getSimpleName().equals( name ) ) {
return DOUBLE;
}
- if ( name.equalsIgnoreCase( "float" )
- || Float.class.getName().equals( name ) ) {
+ if ( Float.class.getName().equals( name )
+ || Float.class.getSimpleName().equals( name ) ) {
return FLOAT;
}
- if ( name.equalsIgnoreCase( "biginteger" )
- || name.equalsIgnoreCase( "big_integer" )
- || BigInteger.class.getName().equals( name ) ) {
+ if ( BigInteger.class.getName().equals( name )
+ || BigInteger.class.getSimpleName().equals( name ) ) {
return BIG_INTEGER;
}
- if ( name.equalsIgnoreCase( "bigdecimal" )
- || name.equalsIgnoreCase( "big_decimal" )
- || BigDecimal.class.getName().equals( name ) ) {
+ if ( BigDecimal.class.getName().equals( name )
+ || BigDecimal.class.getSimpleName().equals( name ) ) {
return BIG_DECIMAL;
}
- if ( name.equalsIgnoreCase( "char" )
- || name.equalsIgnoreCase( "character" )
- || Character.class.getName().equalsIgnoreCase( name ) ) {
- return CHARACTER;
- }
-
- if ( name.equalsIgnoreCase( "string" )
- || String.class.getName().equalsIgnoreCase( name ) ) {
+ if ( String.class.getName().equals( name )
+ || String.class.getSimpleName().equals( name ) ) {
return STRING;
}
- if ( name.equalsIgnoreCase( "instant" )
- || Instant.class.getName().equals( name ) ) {
- return INSTANT;
- }
-
- if ( name.equalsIgnoreCase( "duration" )
- || Duration.class.getName().equals( name ) ) {
- return DURATION;
- }
-
- if ( name.equalsIgnoreCase( "year" )
- || Year.class.getName().equals( name ) ) {
- return YEAR;
+ if ( Character.class.getName().equals( name )
+ || Character.class.getSimpleName().equals( name ) ) {
+ return CHARACTER;
}
- if ( name.equalsIgnoreCase( "localdatetime" )
- || name.equalsIgnoreCase( "local_date_time" )
- || LocalDateTime.class.getName().equals( name ) ) {
- return LOCAL_DATE_TIME;
+ if ( UUID.class.getName().equals( name )
+ || UUID.class.getSimpleName().equals( name ) ) {
+ return UUID;
}
- if ( name.equalsIgnoreCase( "localdate" )
- || name.equalsIgnoreCase( "local_date" )
- || LocalDate.class.getName().equals( name ) ) {
- return LOCAL_DATE;
+ if ( URL.class.getName().equals( name )
+ || URL.class.getSimpleName().equals( name ) ) {
+ return URL;
}
- if ( name.equalsIgnoreCase( "localtime" )
- || name.equalsIgnoreCase( "local_time" )
- || LocalTime.class.getName().equals( name ) ) {
- return LOCAL_TIME;
+ if ( InetAddress.class.getName().equals( name )
+ || InetAddress.class.getSimpleName().equals( name ) ) {
+ return INET_ADDRESS;
}
- if ( name.equalsIgnoreCase( "zoneddatetime" )
- || name.equalsIgnoreCase( "zoned_date_time" )
- || ZonedDateTime.class.getName().equals( name ) ) {
- return ZONED_DATE_TIME;
+ if ( Blob.class.getName().equals( name )
+ || Blob.class.getSimpleName().equals( name ) ) {
+ return BLOB;
}
- if ( name.equalsIgnoreCase( "offsetdatetime" )
- || name.equalsIgnoreCase( "offset_date_time" )
- || OffsetDateTime.class.getName().equals( name ) ) {
- return OFFSET_DATE_TIME;
+ if ( Clob.class.getName().equals( name )
+ || Clob.class.getSimpleName().equals( name ) ) {
+ return CLOB;
}
- if ( name.equalsIgnoreCase( "offsettime" )
- || name.equalsIgnoreCase( "offset_time" )
- || OffsetTime.class.getName().equals( name ) ) {
- return OFFSET_TIME;
+ if ( NClob.class.getName().equals( name )
+ || NClob.class.getSimpleName().equals( name ) ) {
+ return NCLOB;
}
- if ( name.equalsIgnoreCase( "zoneid" )
- || name.equalsIgnoreCase( "zone_id" )
- || ZoneId.class.getName().equals( name ) ) {
- return ZONE_ID;
+ if ( Instant.class.getName().equals( name )
+ || Instant.class.getSimpleName().equals( name ) ) {
+ return INSTANT;
}
- if ( name.equalsIgnoreCase( "zoneoffset" )
- || name.equalsIgnoreCase( "zone_offset" )
- || ZoneOffset.class.getName().equals( name ) ) {
- return ZONE_OFFSET;
+ if ( LocalDate.class.getName().equals( name )
+ || LocalDate.class.getSimpleName().equals( name ) ) {
+ return LOCAL_DATE;
}
- if ( name.equalsIgnoreCase( "uuid" )
- || UUID.class.getName().equals( name ) ) {
- return UUID;
+ if ( LocalTime.class.getName().equals( name )
+ || LocalTime.class.getSimpleName().equals( name ) ) {
+ return LOCAL_TIME;
}
- if ( name.equalsIgnoreCase( "url" )
- || java.net.URL.class.getName().equals( name ) ) {
- return URL;
+ if ( LocalDateTime.class.getName().equals( name )
+ || LocalDateTime.class.getSimpleName().equals( name ) ) {
+ return LOCAL_DATE_TIME;
}
- if ( name.equalsIgnoreCase( "inet" )
- || name.equalsIgnoreCase( "inetaddress" )
- || name.equalsIgnoreCase( "inet_address" )
- || InetAddress.class.getName().equals( name ) ) {
- return INET_ADDRESS;
+ if ( ZonedDateTime.class.getName().equals( name )
+ || ZonedDateTime.class.getSimpleName().equals( name ) ) {
+ return ZONED_DATE_TIME;
}
- if ( name.equalsIgnoreCase( "currency" )
- || Currency.class.getName().equals( name ) ) {
- return CURRENCY;
+ if ( OffsetTime.class.getName().equals( name )
+ || OffsetTime.class.getSimpleName().equals( name ) ) {
+ return OFFSET_TIME;
}
- if ( name.equalsIgnoreCase( "locale" )
- || Locale.class.getName().equals( name ) ) {
- return LOCALE;
+ if ( OffsetDateTime.class.getName().equals( name )
+ || OffsetDateTime.class.getSimpleName().equals( name ) ) {
+ return OFFSET_DATE_TIME;
}
- if ( name.equalsIgnoreCase( "class" )
- || Class.class.getName().equals( name ) ) {
- return CLASS;
+ if ( ZoneId.class.getName().equals( name )
+ || ZoneId.class.getSimpleName().equals( name ) ) {
+ return ZONE_ID;
}
- if ( name.equalsIgnoreCase( "blob" )
- || Blob.class.getName().equals( name ) ) {
- return BLOB;
+ if ( ZoneOffset.class.getName().equals( name )
+ || ZoneOffset.class.getSimpleName().equals( name ) ) {
+ return ZONE_OFFSET;
}
- if ( name.equalsIgnoreCase( "clob" )
- || Clob.class.getName().equals( name ) ) {
- return CLOB;
+ if ( Duration.class.getName().equals( name )
+ || Duration.class.getSimpleName().equals( name ) ) {
+ return DURATION;
}
- if ( name.equalsIgnoreCase( "nclob" )
- || NClob.class.getName().equals( name ) ) {
- return NCLOB;
+ if ( Year.class.getName().equals( name )
+ || Year.class.getSimpleName().equals( name ) ) {
+ return YEAR;
}
- if ( name.equalsIgnoreCase( "timestamp" )
- || name.equalsIgnoreCase( "time_stamp" )
- || java.util.Date.class.getName().equals( name )
- || Timestamp.class.getName().equals( name ) ) {
+ if ( Timestamp.class.getName().equals( name )
+ || Timestamp.class.getSimpleName().equals( name ) ) {
return JDBC_TIMESTAMP;
}
- if ( name.equalsIgnoreCase( "date" )
- || java.sql.Date.class.getName().equals( name ) ) {
+ if ( Date.class.getName().equals( name )
+ || Date.class.getSimpleName().equals( name ) ) {
return JDBC_DATE;
}
- if ( name.equalsIgnoreCase( "time" )
- || java.sql.Time.class.getName().equals( name ) ) {
+ if ( Time.class.getName().equals( name )
+ || Time.class.getSimpleName().equals( name ) ) {
return JDBC_TIME;
}
- if ( name.equalsIgnoreCase( "calendar" )
- || name.equalsIgnoreCase( "gregoriancalendar" )
- || name.equalsIgnoreCase( "gregorian_calendar" )
- || Calendar.class.getName().equals( name )
- || GregorianCalendar.class.getName().equals( name ) ) {
+ if ( Calendar.class.getName().equals( name )
+ || Calendar.class.getSimpleName().equals( name )
+ || GregorianCalendar.class.getName().equals( name )
+ || GregorianCalendar.class.getSimpleName().equals( name ) ) {
return CALENDAR;
}
- if ( name.equalsIgnoreCase( "timezone" )
- || name.equalsIgnoreCase( "time_zone" )
- || TimeZone.class.getName().equals( name ) ) {
+ if ( TimeZone.class.getName().equals( name )
+ || TimeZone.class.getSimpleName().equals( name ) ) {
return TIME_ZONE;
}
+ if ( Currency.class.getName().equals( name )
+ || Currency.class.getSimpleName().equals( name ) ) {
+ return CURRENCY;
+ }
+
+ if ( Locale.class.getName().equals( name )
+ || Locale.class.getSimpleName().equals( name ) ) {
+ return LOCALE;
+ }
+
+ if ( Class.class.getName().equals( name )
+ || Class.class.getSimpleName().equals( name ) ) {
+ return CLASS;
+ }
+
return null;
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/XmlAnnotationHelper.java b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/XmlAnnotationHelper.java
index ea1ef80fcb86..9a944d0b0b50 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/XmlAnnotationHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/XmlAnnotationHelper.java
@@ -8,6 +8,17 @@
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.net.URL;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.NClob;
+import java.time.Instant;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.OffsetDateTime;
+import java.time.OffsetTime;
+import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -65,57 +76,7 @@
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.models.XmlAnnotations;
-import org.hibernate.boot.models.annotations.internal.AssociationOverrideJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.AssociationOverridesJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.AttributeOverrideJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.AttributeOverridesJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.CascadeAnnotation;
-import org.hibernate.boot.models.annotations.internal.CheckConstraintJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.CollectionClassificationXmlAnnotation;
-import org.hibernate.boot.models.annotations.internal.CollectionIdAnnotation;
-import org.hibernate.boot.models.annotations.internal.CollectionTypeAnnotation;
-import org.hibernate.boot.models.annotations.internal.ColumnJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.ColumnTransformerAnnotation;
-import org.hibernate.boot.models.annotations.internal.ConvertJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.ConvertsJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.DiscriminatorColumnJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.DiscriminatorFormulaAnnotation;
-import org.hibernate.boot.models.annotations.internal.DiscriminatorOptionsAnnotation;
-import org.hibernate.boot.models.annotations.internal.DiscriminatorValueJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.EntityJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.EntityListenersJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.EnumeratedJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.FilterAnnotation;
-import org.hibernate.boot.models.annotations.internal.FilterJoinTableAnnotation;
-import org.hibernate.boot.models.annotations.internal.FilterJoinTablesAnnotation;
-import org.hibernate.boot.models.annotations.internal.FiltersAnnotation;
-import org.hibernate.boot.models.annotations.internal.GeneratedValueJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.GenericGeneratorAnnotation;
-import org.hibernate.boot.models.annotations.internal.IdClassJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.IndexJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.InheritanceJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.JavaTypeAnnotation;
-import org.hibernate.boot.models.annotations.internal.JdbcTypeAnnotation;
-import org.hibernate.boot.models.annotations.internal.JdbcTypeCodeAnnotation;
-import org.hibernate.boot.models.annotations.internal.NaturalIdCacheAnnotation;
-import org.hibernate.boot.models.annotations.internal.NotFoundAnnotation;
-import org.hibernate.boot.models.annotations.internal.ParameterAnnotation;
-import org.hibernate.boot.models.annotations.internal.PrimaryKeyJoinColumnJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.PrimaryKeyJoinColumnsJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.RowIdAnnotation;
-import org.hibernate.boot.models.annotations.internal.SQLJoinTableRestrictionAnnotation;
-import org.hibernate.boot.models.annotations.internal.SQLRestrictionAnnotation;
-import org.hibernate.boot.models.annotations.internal.SecondaryRowAnnotation;
-import org.hibernate.boot.models.annotations.internal.SecondaryRowsAnnotation;
-import org.hibernate.boot.models.annotations.internal.SecondaryTableJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.SecondaryTablesJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.SequenceGeneratorJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.TableGeneratorJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.TableJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.TargetXmlAnnotation;
-import org.hibernate.boot.models.annotations.internal.TemporalJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.UniqueConstraintJpaAnnotation;
-import org.hibernate.boot.models.annotations.internal.UuidGeneratorAnnotation;
+import org.hibernate.boot.models.annotations.internal.*;
import org.hibernate.boot.models.annotations.spi.CustomSqlDetails;
import org.hibernate.boot.models.annotations.spi.DatabaseObjectDetails;
import org.hibernate.boot.models.JpaEventListenerStyle;
@@ -390,6 +351,23 @@ public static void applyCollectionId(
if ( generator != null && isNotEmpty( generator.getGenerator() ) ) {
collectionIdAnn.generator( generator.getGenerator() );
}
+
+ if ( StringHelper.isNotEmpty( jaxbCollectionId.getTarget() ) ) {
+ final SimpleTypeInterpretation simpleTypeInterpretation = SimpleTypeInterpretation.interpret(
+ jaxbCollectionId.getTarget()
+ );
+ assert simpleTypeInterpretation != null;
+
+ final CollectionIdJavaClassAnnotation annotationUsage = (CollectionIdJavaClassAnnotation) memberDetails.applyAnnotationUsage(
+ HibernateAnnotations.COLLECTION_ID_JAVA_CLASS,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ annotationUsage.idType( simpleTypeInterpretation.getJavaType() );
+ }
+ else {
+ // this will likely lead to an error later.
+ // should we throw an exception here?
+ }
}
public static void applyCascading(
@@ -1001,6 +979,39 @@ else if ( Character.class.getSimpleName().equalsIgnoreCase( name ) ) {
else if ( UUID.class.getSimpleName().equalsIgnoreCase( name ) ) {
name = Character.class.getName();
}
+ else if ( URL.class.getSimpleName().equalsIgnoreCase( name ) ) {
+ name = URL.class.getName();
+ }
+ else if ( Blob.class.getSimpleName().equalsIgnoreCase( name ) ) {
+ name = Blob.class.getName();
+ }
+ else if ( Clob.class.getSimpleName().equalsIgnoreCase( name ) ) {
+ name = Clob.class.getName();
+ }
+ else if ( NClob.class.getSimpleName().equalsIgnoreCase( name ) ) {
+ name = NClob.class.getName();
+ }
+ else if ( Instant.class.getSimpleName().equalsIgnoreCase( name ) ) {
+ name = Instant.class.getName();
+ }
+ else if ( LocalDate.class.getSimpleName().equalsIgnoreCase( name ) ) {
+ name = LocalDate.class.getName();
+ }
+ else if ( LocalTime.class.getSimpleName().equalsIgnoreCase( name ) ) {
+ name = LocalTime.class.getName();
+ }
+ else if ( LocalDateTime.class.getSimpleName().equalsIgnoreCase( name ) ) {
+ name = LocalDateTime.class.getName();
+ }
+ else if ( ZonedDateTime.class.getSimpleName().equalsIgnoreCase( name ) ) {
+ name = ZonedDateTime.class.getName();
+ }
+ else if ( OffsetTime.class.getSimpleName().equalsIgnoreCase( name ) ) {
+ name = OffsetTime.class.getName();
+ }
+ else if ( OffsetDateTime.class.getSimpleName().equalsIgnoreCase( name ) ) {
+ name = OffsetDateTime.class.getName();
+ }
else {
name = StringHelper.qualifyConditionallyIfNot( packageName, name );
}
@@ -1018,9 +1029,6 @@ public static void applyBasicTypeComposition(
else if ( jaxbBasicMapping.getJavaType() != null ) {
applyJavaTypeDescriptor( jaxbBasicMapping.getJavaType(), memberDetails, xmlDocumentContext );
}
- else if ( isNotEmpty( jaxbBasicMapping.getTarget() ) ) {
- applyTargetClass( jaxbBasicMapping.getTarget(), memberDetails, xmlDocumentContext );
- }
if ( isNotEmpty( jaxbBasicMapping.getJdbcType() ) ) {
applyJdbcTypeDescriptor( jaxbBasicMapping.getJdbcType(), memberDetails, xmlDocumentContext );
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/AnyMappingAttributeProcessing.java b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/AnyMappingAttributeProcessing.java
index d418cd1a9cb1..1430ec351202 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/AnyMappingAttributeProcessing.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/AnyMappingAttributeProcessing.java
@@ -4,14 +4,14 @@
*/
package org.hibernate.boot.models.xml.internal.attr;
-import java.util.List;
-
+import jakarta.persistence.AccessType;
+import jakarta.persistence.DiscriminatorType;
+import jakarta.persistence.JoinColumn;
import org.hibernate.annotations.AnyDiscriminatorValue;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyDiscriminatorValueMappingImpl;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyMappingDiscriminatorImpl;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyMapping;
import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyMappingImpl;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyMappingKeyImpl;
import org.hibernate.boot.jaxb.mapping.spi.JaxbColumnImpl;
+import org.hibernate.boot.jaxb.mapping.spi.JaxbDiscriminatorMapping;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.boot.models.JpaAnnotations;
import org.hibernate.boot.models.annotations.internal.AnyAnnotation;
@@ -19,9 +19,11 @@
import org.hibernate.boot.models.annotations.internal.AnyDiscriminatorValueAnnotation;
import org.hibernate.boot.models.annotations.internal.AnyDiscriminatorValuesAnnotation;
import org.hibernate.boot.models.annotations.internal.AnyKeTypeAnnotation;
+import org.hibernate.boot.models.annotations.internal.AnyKeyJavaClassAnnotation;
import org.hibernate.boot.models.annotations.internal.ColumnJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.JoinColumnJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.JoinColumnsJpaAnnotation;
+import org.hibernate.boot.models.xml.internal.SimpleTypeInterpretation;
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
@@ -31,15 +33,15 @@
import org.hibernate.models.spi.MutableClassDetails;
import org.hibernate.models.spi.MutableMemberDetails;
-import jakarta.persistence.AccessType;
-import jakarta.persistence.DiscriminatorType;
-import jakarta.persistence.JoinColumn;
+import java.util.List;
import static org.hibernate.boot.models.HibernateAnnotations.ANY_DISCRIMINATOR_VALUE;
import static org.hibernate.boot.models.JpaAnnotations.JOIN_COLUMN;
-import static org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing.*;
import static org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing.applyAccess;
import static org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing.applyAttributeAccessor;
+import static org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing.applyFetching;
+import static org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing.applyOptimisticLock;
+import static org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing.applyOptionality;
import static org.hibernate.internal.util.NullnessHelper.coalesce;
/**
@@ -77,11 +79,11 @@ public static MutableMemberDetails processAnyMappingAttribute(
return memberDetails;
}
- private static void applyDiscriminator(
+ static void applyDiscriminator(
MutableMemberDetails memberDetails,
- JaxbAnyMappingImpl jaxbHbmAnyMapping,
+ JaxbAnyMapping jaxbHbmAnyMapping,
XmlDocumentContext xmlDocumentContext) {
- final JaxbAnyMappingDiscriminatorImpl jaxbDiscriminator = jaxbHbmAnyMapping.getDiscriminator();
+ final JaxbAnyMapping.Discriminator jaxbDiscriminator = jaxbHbmAnyMapping.getDiscriminator();
final AnyDiscriminatorAnnotation anyDiscriminatorAnn = (AnyDiscriminatorAnnotation) memberDetails.applyAnnotationUsage(
HibernateAnnotations.ANY_DISCRIMINATOR,
xmlDocumentContext.getModelBuildingContext()
@@ -105,7 +107,7 @@ private static void applyDiscriminator(
columnAnn.apply( jaxbColumn, xmlDocumentContext );
}
- final List jaxbValueMappings = jaxbDiscriminator.getValueMappings();
+ final List extends JaxbDiscriminatorMapping> jaxbValueMappings = jaxbDiscriminator.getValueMappings();
if ( CollectionHelper.isNotEmpty( jaxbValueMappings ) ) {
final AnyDiscriminatorValuesAnnotation discriminatorValuesUsage = (AnyDiscriminatorValuesAnnotation) memberDetails.replaceAnnotationUsage(
ANY_DISCRIMINATOR_VALUE,
@@ -120,14 +122,14 @@ private static void applyDiscriminator(
}
private static AnyDiscriminatorValue[] collectDiscriminatorValues(
- List jaxbValueMappings,
+ List extends JaxbDiscriminatorMapping> jaxbValueMappings,
XmlDocumentContext xmlDocumentContext) {
final AnyDiscriminatorValue[] values = new AnyDiscriminatorValue[jaxbValueMappings.size()];
for ( int i = 0; i < jaxbValueMappings.size(); i++ ) {
final AnyDiscriminatorValueAnnotation valueAnn = ANY_DISCRIMINATOR_VALUE.createUsage( xmlDocumentContext.getModelBuildingContext() );
values[i] = valueAnn;
- final JaxbAnyDiscriminatorValueMappingImpl jaxbValue = jaxbValueMappings.get( i );
+ final JaxbDiscriminatorMapping jaxbValue = jaxbValueMappings.get( i );
valueAnn.discriminator( jaxbValue.getDiscriminatorValue() );
@@ -141,11 +143,11 @@ private static AnyDiscriminatorValue[] collectDiscriminatorValues(
return values;
}
- private static void applyKey(
+ static void applyKey(
MutableMemberDetails memberDetails,
- JaxbAnyMappingImpl jaxbHbmAnyMapping,
+ JaxbAnyMapping jaxbHbmAnyMapping,
XmlDocumentContext xmlDocumentContext) {
- final JaxbAnyMappingKeyImpl jaxbKey = jaxbHbmAnyMapping.getKey();
+ final JaxbAnyMapping.Key jaxbKey = jaxbHbmAnyMapping.getKey();
if ( StringHelper.isNotEmpty( jaxbKey.getType() ) ) {
final AnyKeTypeAnnotation keyTypeUsage = (AnyKeTypeAnnotation) memberDetails.applyAnnotationUsage(
HibernateAnnotations.ANY_KEY_TYPE,
@@ -153,6 +155,13 @@ private static void applyKey(
);
keyTypeUsage.value( jaxbKey.getType() );
}
+ else if ( StringHelper.isNotEmpty( jaxbKey.getJavaClass() ) ) {
+ final AnyKeyJavaClassAnnotation keyJavaType = (AnyKeyJavaClassAnnotation) memberDetails.applyAnnotationUsage(
+ HibernateAnnotations.ANY_KEY_JAVA_CLASS,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+ keyJavaType.value( resolveKeyType( jaxbKey.getJavaClass(), xmlDocumentContext ) );
+ }
if ( jaxbKey.getColumns().isEmpty() ) {
memberDetails.applyAnnotationUsage( JpaAnnotations.JOIN_COLUMN, xmlDocumentContext.getModelBuildingContext() );
@@ -177,4 +186,17 @@ private static void applyKey(
}
}
+ private static Class> resolveKeyType(String name, XmlDocumentContext xmlDocumentContext) {
+ final SimpleTypeInterpretation simpleTypeInterpretation = SimpleTypeInterpretation.interpret( name );
+ if ( simpleTypeInterpretation != null ) {
+ return simpleTypeInterpretation.getJavaType();
+ }
+
+ return xmlDocumentContext
+ .getBootstrapContext()
+ .getModelsContext()
+ .getClassLoading()
+ .classForName( xmlDocumentContext.resolveClassName( name ) );
+ }
+
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/CommonPluralAttributeProcessing.java b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/CommonPluralAttributeProcessing.java
index 2127d5e1d101..e4746da126ef 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/CommonPluralAttributeProcessing.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/CommonPluralAttributeProcessing.java
@@ -11,8 +11,6 @@
import org.hibernate.boot.jaxb.mapping.spi.JaxbPluralFetchModeImpl;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.boot.models.JpaAnnotations;
-import org.hibernate.boot.models.XmlAnnotations;
-import org.hibernate.boot.models.annotations.internal.CollectionClassificationXmlAnnotation;
import org.hibernate.boot.models.annotations.internal.FetchAnnotation;
import org.hibernate.boot.models.annotations.internal.MapKeyClassJpaAnnotation;
import org.hibernate.boot.models.annotations.internal.MapKeyColumnJpaAnnotation;
@@ -56,11 +54,11 @@ public static void applyPluralAttributeStructure(
memberDetails.applyAnnotationUsage( HibernateAnnotations.BAG, buildingContext );
}
else {
- final CollectionClassificationXmlAnnotation collectionClassificationAnn = (CollectionClassificationXmlAnnotation) memberDetails.applyAnnotationUsage(
- XmlAnnotations.COLLECTION_CLASSIFICATION,
- buildingContext
+ XmlAnnotationHelper.applyCollectionClassification(
+ jaxbPluralAttribute.getClassification(),
+ memberDetails,
+ xmlDocumentContext
);
- collectionClassificationAnn.value( jaxbPluralAttribute.getClassification() );
}
}
@@ -71,12 +69,6 @@ public static void applyPluralAttributeStructure(
XmlAnnotationHelper.applyCollectionId( jaxbPluralAttribute.getCollectionId(), memberDetails, xmlDocumentContext );
- XmlAnnotationHelper.applyCollectionClassification(
- jaxbPluralAttribute.getClassification(),
- memberDetails,
- xmlDocumentContext
- );
-
if ( StringHelper.isNotEmpty( jaxbPluralAttribute.getOrderBy() ) ) {
final OrderByJpaAnnotation orderByAnn = (OrderByJpaAnnotation) memberDetails.applyAnnotationUsage(
JpaAnnotations.ORDER_BY,
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/PluralAnyMappingAttributeProcessing.java b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/PluralAnyMappingAttributeProcessing.java
index ff1bdb1434cf..1460e6153928 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/PluralAnyMappingAttributeProcessing.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/internal/attr/PluralAnyMappingAttributeProcessing.java
@@ -4,15 +4,24 @@
*/
package org.hibernate.boot.models.xml.internal.attr;
+import jakarta.persistence.AccessType;
import org.hibernate.boot.jaxb.mapping.spi.JaxbPluralAnyMappingImpl;
+import org.hibernate.boot.models.HibernateAnnotations;
+import org.hibernate.boot.models.annotations.internal.ManyToAnyAnnotation;
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
import org.hibernate.boot.models.xml.internal.XmlProcessingHelper;
+import org.hibernate.boot.models.xml.internal.db.TableProcessing;
import org.hibernate.boot.models.xml.spi.XmlDocumentContext;
import org.hibernate.models.spi.MutableClassDetails;
import org.hibernate.models.spi.MutableMemberDetails;
-import jakarta.persistence.AccessType;
-
+import static org.hibernate.boot.models.xml.internal.attr.AnyMappingAttributeProcessing.applyDiscriminator;
+import static org.hibernate.boot.models.xml.internal.attr.AnyMappingAttributeProcessing.applyKey;
+import static org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing.applyAccess;
+import static org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing.applyAttributeAccessor;
+import static org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing.applyFetching;
+import static org.hibernate.boot.models.xml.internal.attr.CommonAttributeProcessing.applyOptimisticLock;
+import static org.hibernate.boot.models.xml.internal.attr.CommonPluralAttributeProcessing.applyPluralAttributeStructure;
import static org.hibernate.internal.util.NullnessHelper.coalesce;
/**
@@ -32,8 +41,25 @@ public static MutableMemberDetails processPluralAnyMappingAttributes(
accessType,
declarer
);
+
+ final ManyToAnyAnnotation manyToAnyAnn = (ManyToAnyAnnotation) memberDetails.applyAnnotationUsage(
+ HibernateAnnotations.MANY_TO_ANY,
+ xmlDocumentContext.getModelBuildingContext()
+ );
+
+ applyAccess( accessType, memberDetails, xmlDocumentContext );
+ applyAttributeAccessor( jaxbHbmManyToAny, memberDetails, xmlDocumentContext );
+ applyFetching( jaxbHbmManyToAny, memberDetails, manyToAnyAnn, xmlDocumentContext );
+ applyOptimisticLock( jaxbHbmManyToAny, memberDetails, xmlDocumentContext );
+
+ applyDiscriminator( memberDetails, jaxbHbmManyToAny, xmlDocumentContext );
+ applyKey( memberDetails, jaxbHbmManyToAny, xmlDocumentContext );
+
XmlAnnotationHelper.applyCascading( jaxbHbmManyToAny.getCascade(), memberDetails, xmlDocumentContext );
- throw new UnsupportedOperationException( "Support for many-to-any attributes not yet implemented" );
+ applyPluralAttributeStructure( jaxbHbmManyToAny, memberDetails, xmlDocumentContext );
+ TableProcessing.transformJoinTable( jaxbHbmManyToAny.getJoinTable(), memberDetails, xmlDocumentContext );
+
+ return memberDetails;
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/spi/XmlDocumentContext.java b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/spi/XmlDocumentContext.java
index c0680ec8d5cd..c8a6d689d9f8 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/models/xml/spi/XmlDocumentContext.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/spi/XmlDocumentContext.java
@@ -4,37 +4,14 @@
*/
package org.hibernate.boot.models.xml.spi;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
import org.hibernate.HibernateException;
-import org.hibernate.boot.internal.LimitedCollectionClassification;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbAnyMapping;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbAssociationAttribute;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbBasicMapping;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddedMapping;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistentAttribute;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbPluralAttribute;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbUserTypeImpl;
-import org.hibernate.boot.models.internal.ModelsHelper;
+import org.hibernate.boot.models.xml.internal.SimpleTypeInterpretation;
import org.hibernate.boot.models.xml.internal.XmlAnnotationHelper;
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.EffectiveMappingDefaults;
import org.hibernate.internal.util.StringHelper;
-import org.hibernate.models.internal.dynamic.DynamicClassDetails;
-import org.hibernate.models.spi.ClassDetails;
import org.hibernate.models.spi.MutableClassDetails;
import org.hibernate.models.spi.ModelsContext;
-import org.hibernate.type.descriptor.java.JavaType;
-import org.hibernate.type.descriptor.jdbc.JdbcType;
-import org.hibernate.usertype.UserType;
-
-import org.checkerframework.checker.nullness.qual.NonNull;
-
-import static org.hibernate.internal.util.NullnessHelper.nullif;
-import static org.hibernate.internal.util.StringHelper.isNotEmpty;
/**
* Context for a specific XML mapping file
@@ -73,131 +50,12 @@ default MutableClassDetails resolveJavaType(String name) {
}
}
- /**
- * Resolve a ClassDetails by name, accounting for XML-defined package name if one.
- */
- default MutableClassDetails resolveDynamicJavaType(JaxbPersistentAttribute jaxbPersistentAttribute) {
- if ( jaxbPersistentAttribute instanceof JaxbBasicMapping jaxbBasicMapping ) {
- // , ,
-
- // explicit
- final String target = jaxbBasicMapping.getTarget();
- if ( isNotEmpty( target ) ) {
- return (MutableClassDetails) XmlAnnotationHelper.resolveJavaType( target, this );
- }
-
- // UserType
- final JaxbUserTypeImpl userTypeNode = jaxbBasicMapping.getType();
- if ( userTypeNode != null ) {
- final String userTypeImplName = userTypeNode.getValue();
- if ( isNotEmpty( userTypeImplName ) ) {
- final ClassDetails userTypeImplDetails = XmlAnnotationHelper.resolveJavaType( userTypeImplName, this );
- // safe to convert to class, though unfortunate to have to instantiate it...
- final UserType> userType = createInstance( userTypeImplDetails );
- final Class> modelClass = userType.returnedClass();
- return (MutableClassDetails) getModelBuildingContext().getClassDetailsRegistry().getClassDetails( modelClass.getName() );
- }
- }
-
- // JavaType
- final String javaTypeImplName = jaxbBasicMapping.getJavaType();
- if ( isNotEmpty( javaTypeImplName ) ) {
- final ClassDetails javaTypeImplDetails = XmlAnnotationHelper.resolveJavaType( javaTypeImplName, this );
- // safe to convert to class, though unfortunate to have to instantiate it...
- final JavaType> javaType = createInstance( javaTypeImplDetails );
- final Class> modelClass = javaType.getJavaTypeClass();
- return (MutableClassDetails) getModelBuildingContext().getClassDetailsRegistry().getClassDetails( modelClass.getName() );
- }
-
- // JdbcType
- final String jdbcTypeImplName = jaxbBasicMapping.getJdbcType();
- final Integer jdbcTypeCode = jaxbBasicMapping.getJdbcTypeCode();
- final JdbcType jdbcType;
- if ( isNotEmpty( jdbcTypeImplName ) ) {
- final ClassDetails jdbcTypeImplDetails = XmlAnnotationHelper.resolveJavaType( javaTypeImplName, this );
- jdbcType = createInstance( jdbcTypeImplDetails );
- }
- else if ( jdbcTypeCode != null ) {
- jdbcType = getBootstrapContext().getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( jdbcTypeCode );
- }
- else {
- jdbcType = null;
- }
- if ( jdbcType != null ) {
- final JavaType> javaType = jdbcType.getJdbcRecommendedJavaTypeMapping( 0, 0, getBootstrapContext().getTypeConfiguration() );
- final Class> modelClass = javaType.getJavaTypeClass();
- return (MutableClassDetails) getModelBuildingContext().getClassDetailsRegistry().getClassDetails( modelClass.getName() );
- }
-
- // fall through to exception
- }
-
- if ( jaxbPersistentAttribute instanceof JaxbEmbeddedMapping jaxbEmbeddedMapping ) {
- // ,
- final String target = jaxbEmbeddedMapping.getTarget();
- if ( isNotEmpty( target ) ) {
- return (MutableClassDetails) ModelsHelper.resolveClassDetails(
- target,
- getModelBuildingContext().getClassDetailsRegistry(),
- () -> new DynamicClassDetails( target, getModelBuildingContext() )
- );
- }
- // fall through to exception
- }
-
- if ( jaxbPersistentAttribute instanceof JaxbAssociationAttribute jaxbAssociationAttribute ) {
- final String target = jaxbAssociationAttribute.getTargetEntity();
- if ( isNotEmpty( target ) ) {
- return (MutableClassDetails) ModelsHelper.resolveClassDetails(
- target,
- getModelBuildingContext().getClassDetailsRegistry(),
- () -> new DynamicClassDetails(
- target,
- null,
- false,
- null,
- null,
- getModelBuildingContext()
- )
- );
- }
- // fall through to exception
- }
-
- if ( jaxbPersistentAttribute instanceof JaxbAnyMapping ) {
- // todo : this is problematic because we'd really want Object, but the hibernate-models
- // definition of ClassDetails(Object) is immutable. Probably the best option here
- // is to create a new (unregistered) DynamicClassDetails for each
- throw new UnsupportedOperationException( "Not yet implemented" );
- }
-
- if ( jaxbPersistentAttribute instanceof JaxbPluralAttribute jaxbPluralAttribute ) {
- final LimitedCollectionClassification classification = nullif( jaxbPluralAttribute.getClassification(), LimitedCollectionClassification.BAG );
- return switch ( classification ) {
- case BAG -> resolveJavaType( Collection.class.getName() );
- case LIST -> resolveJavaType( List.class.getName() );
- case SET -> resolveJavaType( Set.class.getName() );
- case MAP -> resolveJavaType( Map.class.getName() );
- };
- }
-
- // todo : would be nice to have at least the XML origin (file name, etc) for the exception.
- // the "context" (class where this happens) would be even more nicerer
- throw new HibernateException( "Could not determine target type for dynamic attribute - " + jaxbPersistentAttribute.getName() );
- }
-
- @NonNull
- private T createInstance(ClassDetails classDetails) {
- try {
- //noinspection unchecked
- return (T) classDetails.toJavaClass().getConstructor().newInstance();
- }
- catch (Exception e) {
- throw new HibernateException( "Unable to create instance from incoming ClassDetails - " + classDetails );
+ default String resolveClassName(String specifiedName) {
+ final SimpleTypeInterpretation simpleTypeInterpretation = SimpleTypeInterpretation.interpret( specifiedName );
+ if ( simpleTypeInterpretation != null ) {
+ return simpleTypeInterpretation.getJavaType().getName();
}
- }
- default String resolveClassName(String specifiedName) {
if ( specifiedName.contains( "." ) ) {
return specifiedName;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java
index a04005ab7fb9..695f5fe0566a 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/MetadataContext.java
@@ -525,7 +525,13 @@ private void applyIdMetadata(PersistentClass persistentClass, IdentifiableDo
if ( identifierMapper != null ) {
cidProperties = identifierMapper.getProperties();
propertySpan = identifierMapper.getPropertySpan();
- idClassType = applyIdClassMetadata( (Component) persistentClass.getIdentifier() );
+ if ( identifierMapper.getComponentClassName() == null ) {
+ // support for no id-class, especially for dynamic models
+ idClassType = null;
+ }
+ else {
+ idClassType = applyIdClassMetadata( (Component) persistentClass.getIdentifier() );
+ }
}
else {
cidProperties = compositeId.getProperties();
diff --git a/hibernate-core/src/main/resources/org/hibernate/xsd/mapping/mapping-7.0.xsd b/hibernate-core/src/main/resources/org/hibernate/xsd/mapping/mapping-7.0.xsd
index 5b54853067ce..1118b61457f8 100644
--- a/hibernate-core/src/main/resources/org/hibernate/xsd/mapping/mapping-7.0.xsd
+++ b/hibernate-core/src/main/resources/org/hibernate/xsd/mapping/mapping-7.0.xsd
@@ -3163,7 +3163,10 @@
-
+
+
+
+
@@ -3196,6 +3199,8 @@
+
+
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/cid/AbstractCompositeIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/cid/AbstractCompositeIdTest.java
deleted file mode 100644
index 7be41fbbb218..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/cid/AbstractCompositeIdTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.abstractembeddedcomponents.cid;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author Steve Ebersole
- */
-@DomainModel(
- xmlMappings = "org/hibernate/orm/test/abstractembeddedcomponents/cid/Mappings.hbm.xml"
-)
-@SessionFactory
-public class AbstractCompositeIdTest {
-
- @Test
- public void testEmbeddedCompositeIdentifierOnAbstractClass(SessionFactoryScope scope) {
- MyInterfaceImpl myInterface = new MyInterfaceImpl();
- myInterface.setKey1( "key1" );
- myInterface.setKey2( "key2" );
- myInterface.setName( "test" );
-
- scope.inTransaction(
- session -> {
- session.persist( myInterface );
- session.flush();
-
- session.createQuery( "from MyInterface" ).list();
-
- session.remove( myInterface );
- }
- );
-
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/cid/MyInterface.java b/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/cid/MyInterface.java
deleted file mode 100644
index fb8c20265c90..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/cid/MyInterface.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.abstractembeddedcomponents.cid;
-import java.io.Serializable;
-
-/**
- * @author Steve Ebersole
- */
-public interface MyInterface extends Serializable {
- public String getKey1();
- public void setKey1(String key1);
- public String getKey2();
- public void setKey2(String key2);
- public String getName();
- public void setName(String name);
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/cid/MyInterfaceImpl.java b/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/cid/MyInterfaceImpl.java
deleted file mode 100644
index 25bf8d9738db..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/cid/MyInterfaceImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.abstractembeddedcomponents.cid;
-
-
-
-/**
- * @author Steve Ebersole
- */
-public class MyInterfaceImpl implements MyInterface {
- private String key1;
- private String key2;
- private String name;
-
- public String getKey1() {
- return key1;
- }
-
- public void setKey1(String key1) {
- this.key1 = key1;
- }
-
- public String getKey2() {
- return key2;
- }
-
- public void setKey2(String key2) {
- this.key2 = key2;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java
deleted file mode 100644
index d8de6564f21b..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/AbstractComponentPropertyRefTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.abstractembeddedcomponents.propertyref;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-
-
-/**
- * @author Steve Ebersole
- */
-@DomainModel(
- xmlMappings = "org/hibernate/orm/test/abstractembeddedcomponents/propertyref/Mappings.hbm.xml"
-)
-@SessionFactory
-public class AbstractComponentPropertyRefTest {
- public String[] getMappings() {
- return new String[] {};
- }
-
- @Test
- public void testPropertiesRefCascades(SessionFactoryScope scope) {
- ServerImpl server = new ServerImpl();
- AddressImpl address = new AddressImpl();
- scope.inTransaction(
- session -> {
- session.persist( server );
- server.setAddress( address );
- address.setServer( server );
- session.flush();
- session.createQuery( "from Server s join fetch s.address" ).list();
- }
- );
-
- assertNotNull( server.getId() );
- assertNotNull( address.getId() );
-
- scope.inTransaction(
- session -> {
- session.remove( address );
- session.remove( server );
- }
- );
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/Address.java b/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/Address.java
deleted file mode 100644
index 5bdc5cefe9c5..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/Address.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.abstractembeddedcomponents.propertyref;
-
-
-/**
- * @author Steve Ebersole
- */
-public interface Address {
- public Long getId();
- public void setId(Long id);
- public String getAddressType();
- public void setAddressType(String addressType);
- public Server getServer();
- public void setServer(Server server);
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/AddressImpl.java b/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/AddressImpl.java
deleted file mode 100644
index e83cd43fb835..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/AddressImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.abstractembeddedcomponents.propertyref;
-
-
-
-/**
- * @author Steve Ebersole
- */
-public class AddressImpl implements Address {
- private Long id;
- private String addressType;
- private Server server;
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getAddressType() {
- return addressType;
- }
-
- public void setAddressType(String addressType) {
- this.addressType = addressType;
- }
-
- public Server getServer() {
- return server;
- }
-
- public void setServer(Server server) {
- this.server = server;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/Server.java b/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/Server.java
deleted file mode 100644
index d759ad343560..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/Server.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.abstractembeddedcomponents.propertyref;
-
-
-
-/**
- * @author Steve Ebersole
- */
-public interface Server {
- public Long getId();
- public void setId(Long id);
- public String getServerType();
- public void setServerType(String serverType);
- public Address getAddress();
- public void setAddress(Address address);
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/ServerImpl.java b/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/ServerImpl.java
deleted file mode 100644
index 1c6a930acd66..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/ServerImpl.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.abstractembeddedcomponents.propertyref;
-
-
-
-/**
- * @author Steve Ebersole
- */
-public class ServerImpl implements Server {
- private Long id;
- private String serverType;
- private Address address;
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getServerType() {
- return serverType;
- }
-
- public void setServerType(String serverType) {
- this.serverType = serverType;
- }
-
- public Address getAddress() {
- return address;
- }
-
- public void setAddress(Address address) {
- this.address = address;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/ConfigurationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/ConfigurationTest.java
deleted file mode 100644
index a33b1f0ec699..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/ConfigurationTest.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations;
-
-import org.hibernate.SessionFactory;
-import org.hibernate.cfg.MappingSettings;
-import org.hibernate.query.Query;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
-
-import org.hibernate.query.sqm.UnknownEntityException;
-
-import org.hibernate.testing.util.ServiceRegistryUtil;
-import org.junit.jupiter.api.Test;
-
-import static org.hibernate.testing.transaction.TransactionUtil2.inTransaction;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
-
-/**
- * @author Emmanuel Bernard
- */
-public class ConfigurationTest {
- @Test
- public void testDeclarativeMix() {
- Configuration cfg = new Configuration();
- ServiceRegistryUtil.applySettings( cfg.getStandardServiceRegistryBuilder() );
- cfg.configure( "org/hibernate/orm/test/annotations/hibernate.cfg.xml" );
- cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
- try (SessionFactory sf = cfg.buildSessionFactory()) {
- assertNotNull( sf );
- Session s = sf.openSession();
- Transaction tx = s.beginTransaction();
- Query q = s.createQuery( "from Boat" );
- assertEquals( 0, q.list().size() );
- q = s.createQuery( "from Plane" );
- assertEquals( 0, q.list().size() );
- tx.commit();
- s.close();
- }
- }
-
- @Test
- public void testIgnoringHbm() {
- Configuration cfg = new Configuration();
- ServiceRegistryUtil.applySettings( cfg.getStandardServiceRegistryBuilder() );
- cfg.configure( "org/hibernate/orm/test/annotations/hibernate.cfg.xml" );
- cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
- cfg.setProperty( MappingSettings.XML_MAPPING_ENABLED, false );
-
- try ( SessionFactoryImplementor sf = (SessionFactoryImplementor) cfg.buildSessionFactory() ) {
- assertNotNull( sf );
-
- inTransaction(
- sf,
- session -> {
- try {
- session.createQuery( "from Boat" ).list();
- fail( "Boat should not be mapped" );
- }
- catch (IllegalArgumentException expected) {
- assertEquals( UnknownEntityException.class, expected.getCause().getClass() );
- // expected outcome
-
- // see org.hibernate.test.jpa.compliance.tck2_2.QueryApiTest#testInvalidQueryMarksTxnForRollback
- // for testing of how this invalid query String case is handled in terms of transactions
- }
- }
- );
-
-
- inTransaction(
- sf,
- session -> {
- assertEquals( 0, session.createQuery( "from Plane" ).list().size() );
- }
- );
- }
- }
-
- @Test
- public void testPrecedenceHbm() {
- Configuration cfg = new Configuration();
- ServiceRegistryUtil.applySettings( cfg.getStandardServiceRegistryBuilder() );
- cfg.configure( "org/hibernate/orm/test/annotations/hibernate.cfg.xml" );
- cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
- cfg.addAnnotatedClass( Boat.class );
- try (SessionFactory sf = cfg.buildSessionFactory()) {
- assertNotNull( sf );
- Session s = sf.openSession();
- s.getTransaction().begin();
- Boat boat = new Boat();
- boat.setSize( 12 );
- boat.setWeight( 34 );
- s.persist( boat );
- s.getTransaction().commit();
- s.clear();
- Transaction tx = s.beginTransaction();
- boat = (Boat) s.get( Boat.class, boat.getId() );
- assertTrue( 34 != boat.getWeight(), "Annotation has precedence" );
- s.remove( boat );
- //s.getTransaction().commit();
- tx.commit();
- s.close();
- }
- }
-
- @Test
- public void testHbmWithSubclassExtends() {
- Configuration cfg = new Configuration();
- ServiceRegistryUtil.applySettings( cfg.getStandardServiceRegistryBuilder() );
- cfg.configure( "org/hibernate/orm/test/annotations/hibernate.cfg.xml" );
- cfg.addClass( Ferry.class );
- cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
- try (SessionFactory sf = cfg.buildSessionFactory()) {
- assertNotNull( sf );
- Session s = sf.openSession();
- Transaction tx = s.beginTransaction();
- Query q = s.createQuery( "from Ferry" );
- assertEquals( 0, q.list().size() );
- q = s.createQuery( "from Plane" );
- assertEquals( 0, q.list().size() );
- tx.commit();
- s.close();
- }
- }
-
- @Test
- public void testAnnReferencesHbm() {
- Configuration cfg = new Configuration();
- ServiceRegistryUtil.applySettings( cfg.getStandardServiceRegistryBuilder() );
- cfg.configure( "org/hibernate/orm/test/annotations/hibernate.cfg.xml" );
- cfg.addAnnotatedClass( Port.class );
- cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
- try (SessionFactory sf = cfg.buildSessionFactory()) {
- assertNotNull( sf );
- Session s = sf.openSession();
- Transaction tx = s.beginTransaction();
- Query q = s.createQuery( "from Boat" );
- assertEquals( 0, q.list().size() );
- q = s.createQuery( "from Port" );
- assertEquals( 0, q.list().size() );
- tx.commit();
- s.close();
- }
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/bytecode/Hammer.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/bytecode/Hammer.java
index 2e3e69f9220b..24dbe715fd04 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/bytecode/Hammer.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/bytecode/Hammer.java
@@ -4,21 +4,30 @@
*/
package org.hibernate.orm.test.annotations.bytecode;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
/**
* @author Emmanuel Bernard
*/
+@Entity
public class Hammer implements Tool {
private Long id;
+ @Id
+ @GeneratedValue(generator = "increment")
+ @Override
public Long getId() {
return id;
}
+ @Override
public void setId(Long id) {
this.id = id;
}
+ @Override
public Integer usage() {
return 0;
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/bytecode/ProxyBreakingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/bytecode/ProxyBreakingTest.java
index 10f80c65683d..eafbc65e8baf 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/bytecode/ProxyBreakingTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/bytecode/ProxyBreakingTest.java
@@ -5,39 +5,39 @@
package org.hibernate.orm.test.annotations.bytecode;
import org.hibernate.Hibernate;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
-import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Emmanuel Bernard
*/
-public class ProxyBreakingTest extends BaseCoreFunctionalTestCase {
+@SuppressWarnings("JUnitMalformedDeclaration")
+@DomainModel(annotatedClasses = {Tool.class, Hammer.class})
+@SessionFactory
+public class ProxyBreakingTest {
@Test
- public void testProxiedBridgeMethod() throws Exception {
- //bridge methods should not be proxied
- Session s = openSession();
- Transaction tx = s.beginTransaction();
- Hammer h = new Hammer();
- s.persist(h);
- s.flush();
- s.clear();
- assertNotNull( "The proxy creation failure is breaking things", h.getId() );
- h = (Hammer) s.getReference( Hammer.class, h.getId() );
- assertFalse( Hibernate.isInitialized( h ) );
- tx.rollback();
- s.close();
+ public void testProxiedBridgeMethod(SessionFactoryScope factoryScope) {
+ final Hammer persisted = factoryScope.fromTransaction( (session) -> {
+ final Hammer hammer = new Hammer();
+ session.persist( hammer );
+ return hammer;
+ } );
+
+ assertThat( persisted.getId() ).isNotNull();
+
+ factoryScope.inTransaction( (session) -> {
+ final Hammer reference = session.getReference( Hammer.class, persisted.getId() );
+ assertThat( Hibernate.isInitialized( reference ) ).isFalse();
+ } );
}
- @Override
- protected String[] getOrmXmlFiles() {
- return new String[] {
- "org/hibernate/orm/test/annotations/bytecode/Hammer.hbm.xml"
- };
+ @AfterEach
+ void dropTestData(SessionFactoryScope factoryScope) {
+ factoryScope.dropData();
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/bytecode/Tool.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/bytecode/Tool.java
index cb71e5020932..f7bc59555065 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/bytecode/Tool.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/bytecode/Tool.java
@@ -4,14 +4,12 @@
*/
package org.hibernate.orm.test.annotations.bytecode;
-
/**
* @author Emmanuel Bernard
*/
public interface Tool {
- public Long getId();
-
- public void setId(Long id);
+ Long getId();
+ void setId(Long id);
- public Number usage();
+ Number usage();
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/fetchprofile/FetchProfileTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/fetchprofile/FetchProfileTest.java
index fef38f6bfcd4..943f5642bb94 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/fetchprofile/FetchProfileTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/fetchprofile/FetchProfileTest.java
@@ -4,194 +4,112 @@
*/
package org.hibernate.orm.test.annotations.fetchprofile;
-import java.io.InputStream;
-
import org.hibernate.MappingException;
import org.hibernate.boot.MetadataSources;
-import org.hibernate.boot.registry.BootstrapServiceRegistry;
-import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.service.ServiceRegistry;
-
-import org.hibernate.testing.ServiceRegistryBuilder;
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.Jira;
import org.hibernate.testing.orm.junit.JiraKey;
-import org.hibernate.testing.junit4.BaseUnitTestCase;
-import org.hibernate.testing.util.ServiceRegistryUtil;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.hibernate.testing.orm.junit.NotImplementedYet;
+import org.hibernate.testing.orm.junit.ServiceRegistry;
+import org.hibernate.testing.orm.junit.ServiceRegistryScope;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Test case for HHH-4812
*
* @author Hardy Ferentschik
*/
+@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey( value = "HHH-4812" )
-public class FetchProfileTest extends BaseUnitTestCase {
-
- private ServiceRegistry serviceRegistry;
-
- @Before
- public void setUp() {
- serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
- }
-
- @After
- public void tearDown() {
- if (serviceRegistry != null) ServiceRegistryBuilder.destroy(serviceRegistry);
- }
-
+public class FetchProfileTest {
@Test
- public void testFetchProfileConfigured() {
- Configuration config = new Configuration();
- config.addAnnotatedClass( Customer.class );
- config.addAnnotatedClass( Order.class );
- config.addAnnotatedClass( SupportTickets.class );
- config.addAnnotatedClass( Country.class );
- try (SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory(
- serviceRegistry
- )) {
-
- assertTrue(
- "fetch profile not parsed properly",
- sessionImpl.containsFetchProfileDefinition( "customer-with-orders" )
- );
- assertFalse(
- "package info should not be parsed",
- sessionImpl.containsFetchProfileDefinition( "package-profile-1" )
- );
- }
+ @DomainModel(annotatedClasses = {Customer.class, Order.class, SupportTickets.class, Country.class})
+ @SessionFactory
+ public void testFetchProfileConfigured(SessionFactoryScope factoryScope) {
+ final SessionFactoryImplementor sessionFactory = factoryScope.getSessionFactory();
+ assertThat( sessionFactory.containsFetchProfileDefinition( "customer-with-orders" ) ).isTrue();
+ assertThat( sessionFactory.containsFetchProfileDefinition( "package-profile-1" ) ).isFalse();
}
@Test
- public void testWrongAssociationName() {
- final MetadataSources metadataSources = new MetadataSources( ServiceRegistryUtil.serviceRegistry() )
- .addAnnotatedClass( Customer2.class )
- .addAnnotatedClass( Order.class )
- .addAnnotatedClass( Country.class );
+ @ServiceRegistry
+ public void testWrongAssociationName(ServiceRegistryScope registryScope) {
+ final MetadataSources metadataSources = new MetadataSources( registryScope.getRegistry() )
+ .addAnnotatedClasses( Customer2.class, Order.class, Country.class );
try {
metadataSources.buildMetadata();
- fail();
+ fail( "Expecting an exception, but none thrown" );
}
- catch ( MappingException e ) {
- log.trace("success");
- }
- finally {
- ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
- if(metaServiceRegistry instanceof BootstrapServiceRegistry) {
- BootstrapServiceRegistryBuilder.destroy( metaServiceRegistry );
- }
+ catch (MappingException expected) {
}
}
@Test
- public void testWrongClass() {
- final MetadataSources metadataSources = new MetadataSources( ServiceRegistryUtil.serviceRegistry() )
- .addAnnotatedClass( Customer3.class )
- .addAnnotatedClass( Order.class )
- .addAnnotatedClass( Country.class );
+ @ServiceRegistry
+ public void testWrongClass(ServiceRegistryScope registryScope) {
+ final MetadataSources metadataSources = new MetadataSources( registryScope.getRegistry() )
+ .addAnnotatedClasses( Customer2.class, Order.class, Country.class );
try {
metadataSources.buildMetadata();
- fail();
- }
- catch ( MappingException e ) {
- log.trace("success");
+ fail( "Expecting an exception, but none thrown" );
}
- finally {
- ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
- if(metaServiceRegistry instanceof BootstrapServiceRegistry) {
- BootstrapServiceRegistryBuilder.destroy( metaServiceRegistry );
- }
+ catch (MappingException expected) {
}
}
@Test
- public void testNowSupportedFetchMode() {
- final MetadataSources metadataSources = new MetadataSources( ServiceRegistryUtil.serviceRegistry() )
- .addAnnotatedClass( Customer4.class )
- .addAnnotatedClass( Order.class )
- .addAnnotatedClass( Country.class );
-
- try {
- metadataSources.buildMetadata();
- }
- finally {
- ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
- if(metaServiceRegistry instanceof BootstrapServiceRegistry) {
- BootstrapServiceRegistryBuilder.destroy( metaServiceRegistry );
- }
- }
+ @DomainModel(annotatedClasses = {Customer4.class, Order.class, Country.class})
+ @SessionFactory
+ public void testNowSupportedFetchMode(SessionFactoryScope factoryScope) {
+ final SessionFactoryImplementor sessionFactory = factoryScope.getSessionFactory();
+ assertThat( sessionFactory.containsFetchProfileDefinition( "unsupported-fetch-mode" ) ).isTrue();
}
@Test
- public void testXmlOverride() {
- Configuration config = new Configuration();
- config.addAnnotatedClass( Customer5.class );
- config.addAnnotatedClass( Order.class );
- config.addAnnotatedClass( Country.class );
- InputStream is = Thread.currentThread()
- .getContextClassLoader()
- .getResourceAsStream( "org/hibernate/orm/test/annotations/fetchprofile/mappings.hbm.xml" );
- config.addInputStream( is );
- try (SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory(
- serviceRegistry
- )) {
-
- assertTrue(
- "fetch profile not parsed properly",
- sessionImpl.containsFetchProfileDefinition( "orders-profile" )
- );
- }
-
- // now the same with no xml
- final MetadataSources metadataSources = new MetadataSources( ServiceRegistryUtil.serviceRegistry() )
- .addAnnotatedClass( Customer5.class )
- .addAnnotatedClass( Order.class )
- .addAnnotatedClass( Country.class );
+ @ServiceRegistry
+ @NotImplementedYet(reason = "See HHH-19417")
+ @Jira( "https://hibernate.atlassian.net/browse/HHH-19417" )
+ public void testXmlOverride(ServiceRegistryScope registryScope) {
+ final MetadataSources metadataSources = new MetadataSources( registryScope.getRegistry() )
+ .addAnnotatedClasses( Customer5.class, Order.class, Country.class )
+ .addResource( "org/hibernate/orm/test/annotations/fetchprofile/mappings.xml" );
+ // NOTE : until HHH-19417 is addressed, this will fail
+ metadataSources.buildMetadata();
+
+// final SessionFactoryImplementor sessionFactory = factoryScope.getSessionFactory();
+// assertThat( sessionFactory.containsFetchProfileDefinition( "orders-profile" ) ).isTrue();
+ }
+ @Test
+ @ServiceRegistry
+ public void testMissingXmlOverride(ServiceRegistryScope registryScope) {
+ final MetadataSources metadataSources = new MetadataSources( registryScope.getRegistry() )
+ .addAnnotatedClasses( Customer5.class, Order.class, Country.class );
try {
metadataSources.buildMetadata();
- fail();
+ fail( "Expecting an exception, but none thrown" );
}
- catch ( MappingException e ) {
- log.trace("success");
- }
- finally {
- ServiceRegistry metaServiceRegistry = metadataSources.getServiceRegistry();
- if(metaServiceRegistry instanceof BootstrapServiceRegistry) {
- BootstrapServiceRegistryBuilder.destroy( metaServiceRegistry );
- }
+ catch (MappingException expected) {
}
}
@Test
- public void testPackageConfiguredFetchProfile() {
- Configuration config = new Configuration();
- config.addAnnotatedClass( Customer.class );
- config.addAnnotatedClass( Order.class );
- config.addAnnotatedClass( SupportTickets.class );
- config.addAnnotatedClass( Country.class );
- config.addPackage( Customer.class.getPackage().getName() );
- try (SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory(
- serviceRegistry
- )) {
-
- assertTrue(
- "fetch profile not parsed properly",
- sessionImpl.containsFetchProfileDefinition( "package-profile-1" )
- );
- assertTrue(
- "fetch profile not parsed properly",
- sessionImpl.containsFetchProfileDefinition( "package-profile-2" )
- );
- }
+ @DomainModel(
+ annotatedClasses = {Customer.class, Order.class, SupportTickets.class, Country.class},
+ annotatedPackageNames = "org.hibernate.orm.test.annotations.fetchprofile"
+ )
+ @SessionFactory
+ public void testPackageConfiguredFetchProfile(SessionFactoryScope factoryScope) {
+ final SessionFactoryImplementor sessionFactory = factoryScope.getSessionFactory();
+ assertThat( sessionFactory.containsFetchProfileDefinition( "package-profile-1" ) ).isTrue();
+ assertThat( sessionFactory.containsFetchProfileDefinition( "package-profile-2" ) ).isTrue();
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/A.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/A.java
deleted file mode 100644
index 68029b0da1ba..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/A.java
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-
-/**
- * @author Emmanuel Bernard
- */
-public interface A extends java.io.Serializable {
- public Integer getAId();
-
- public void setAId(Integer aId);
-
- String getDescription();
-
- void setDescription(String description);
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/AImpl.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/AImpl.java
deleted file mode 100644
index 5f6e4005c2c9..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/AImpl.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.Id;
-import jakarta.persistence.Inheritance;
-import jakarta.persistence.InheritanceType;
-import jakarta.persistence.Table;
-
-@Entity
-@Inheritance( strategy = InheritanceType.JOINED )
-@Table( name = "ENTITYA" )
-public class AImpl implements A {
- private static final long serialVersionUID = 1L;
-
- private Integer aId = 0;
- private String description;
-
- public AImpl() {
- }
-
- @Id
- @GeneratedValue
- @Column( name = "aID" )
- public Integer getAId() {
- return this.aId;
- }
-
- public void setAId(Integer aId) {
- this.aId = aId;
- }
-
- @Column( name = "description" )
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/B.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/B.java
deleted file mode 100644
index 5f1779f05c5c..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/B.java
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-
-
-/**
- * @author Emmanuel Bernard
- */
-public interface B extends A {
- public Integer getBId();
-
- public void setBId(Integer bId);
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/BImpl.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/BImpl.java
deleted file mode 100644
index 274a2e41f90f..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/BImpl.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-import jakarta.persistence.Entity;
-import jakarta.persistence.Table;
-
-@Entity
-@Table( name = "ENTITYB" )
-public class BImpl extends AImpl implements B {
- private static final long serialVersionUID = 1L;
-
- private Integer bId = 0;
-
- public BImpl() {
- super();
- }
-
- public Integer getBId() {
- return bId;
- }
-
- public void setBId(Integer bId) {
- this.bId = bId;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/CloudType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/CloudType.java
deleted file mode 100644
index a71d310be4f6..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/CloudType.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-
-
-/**
- * @author Emmanuel Bernard
- */
-public class CloudType {
- private Integer id;
- private String name;
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/Government.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/Government.java
deleted file mode 100644
index 0cc10ef9096f..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/Government.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-
-
-/**
- * @author Emmanuel Bernard
- */
-public class Government {
- private Integer id;
- private String name;
- private PrimeMinister primeMinister;
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public PrimeMinister getPrimeMinister() {
- return primeMinister;
- }
-
- public void setPrimeMinister(PrimeMinister primeMinister) {
- this.primeMinister = primeMinister;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/HbmTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/HbmTest.java
deleted file mode 100644
index 118638cc48e7..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/HbmTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-
-import java.util.HashSet;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Test;
-
-
-/**
- * @author Emmanuel Bernard
- */
-@DomainModel(
- annotatedClasses = {
- PrimeMinister.class,
- Sky.class,
- },
- xmlMappings = {
- "org/hibernate/orm/test/annotations/xml/hbm/Government.hbm.xml",
- "org/hibernate/orm/test/annotations/xml/hbm/CloudType.hbm.xml",
- }
-)
-@SessionFactory
-public class HbmTest {
-
- @AfterEach
- public void tearDown(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> {
- session.createQuery( "from Government" ).list().forEach( gov -> {
- session.remove( gov );
-
- } );
- session.createQuery( "from PrimeMinister" ).list().forEach( p -> {
- session.remove( p );
- } );
- session.createMutationQuery( "delete from EarthSky" ).executeUpdate();
- session.createMutationQuery( "delete from CloudType" ).executeUpdate();
- }
- );
- }
-
- @Test
- public void testManyToOne(SessionFactoryScope scope) throws Exception {
- scope.inTransaction(
- session -> {
- Government gov = new Government();
- gov.setName( "Liberals" );
- session.persist( gov );
- PrimeMinister pm = new PrimeMinister();
- pm.setName( "Murray" );
- pm.setCurrentGovernment( gov );
- session.persist( pm );
- }
- );
- }
-
- @Test
- public void testOneToMany(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> {
- Government gov = new Government();
- gov.setName( "Liberals" );
- Government gov2 = new Government();
- gov2.setName( "Liberals2" );
- session.persist( gov );
- session.persist( gov2 );
- PrimeMinister pm = new PrimeMinister();
- pm.setName( "Murray" );
- pm.setCurrentGovernment( gov );
- pm.setGovernments( new HashSet() );
- pm.getGovernments().add( gov2 );
- pm.getGovernments().add( gov );
- gov.setPrimeMinister( pm );
- gov2.setPrimeMinister( pm );
- session.persist( pm );
- session.flush();
- }
- );
- }
-
- @Test
- public void testManyToMany(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> {
- CloudType type = new CloudType();
- type.setName( "Cumulus" );
- Sky sky = new Sky();
- session.persist( type );
- sky.getCloudTypes().add( type );
- session.persist( sky );
- session.flush();
- }
- );
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/HbmWithIdentityTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/HbmWithIdentityTest.java
deleted file mode 100644
index 84d7cadb743f..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/HbmWithIdentityTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-
-
-import org.hibernate.dialect.HANADialect;
-
-import org.hibernate.testing.orm.junit.DialectFeatureChecks;
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.RequiresDialectFeature;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.hibernate.testing.orm.junit.SkipForDialect;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author Emmanuel Bernard
- */
-@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsIdentityColumns.class)
-@DomainModel(
- annotatedClasses = { Sky.class, ZImpl.class },
- xmlMappings = {
- "org/hibernate/orm/test/annotations/xml/hbm/A.hbm.xml",
- "org/hibernate/orm/test/annotations/xml/hbm/B.hbm.xml",
- "org/hibernate/orm/test/annotations/xml/hbm/CloudType.hbm.xml"
- }
-)
-@SessionFactory
-public class HbmWithIdentityTest {
- @Test
- @SkipForDialect(dialectClass = HANADialect.class, matchSubTypes = true, reason = " HANA doesn't support tables consisting of only a single auto-generated column")
- public void testManyToOneAndInterface(SessionFactoryScope scope) {
- scope.inTransaction(
- s -> {
- B b = new BImpl();
- b.setBId( 1 );
- s.persist( b );
- Z z = new ZImpl();
- z.setB( b );
- s.persist( z );
- s.flush();
- }
- );
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/PreParsedHbmXmlTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/PreParsedHbmXmlTest.java
deleted file mode 100644
index 816d9f2e32ac..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/PreParsedHbmXmlTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UncheckedIOException;
-
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.boot.jaxb.spi.Binding;
-
-import org.hibernate.testing.orm.junit.DialectFeatureChecks;
-import org.hibernate.testing.orm.junit.RequiresDialectFeature;
-import org.hibernate.testing.orm.junit.JiraKey;
-import org.hibernate.testing.orm.junit.BaseSessionFactoryFunctionalTest;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-@JiraKey(value = "HHH-14530")
-@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsIdentityColumns.class)
-public class PreParsedHbmXmlTest extends BaseSessionFactoryFunctionalTest {
-
- @Override
- protected void applyMetadataSources(MetadataSources metadataSources) {
- try (InputStream xmlStream = Thread.currentThread().getContextClassLoader()
- .getResourceAsStream( "org/hibernate/orm/test/annotations/xml/hbm/pre-parsed-hbm.xml" )) {
- Binding> parsed = metadataSources.getXmlMappingBinderAccess().bind( xmlStream );
- metadataSources.addXmlBinding( parsed );
- }
- catch (IOException e) {
- throw new UncheckedIOException( e );
- }
- }
-
- @Test
- public void testPreParsedHbmXml() {
- // Just check that the entity can be persisted, which means the mapping file was taken into account
- NonAnnotatedEntity persistedEntity = new NonAnnotatedEntity( "someName" );
- inTransaction( s -> s.persist( persistedEntity ) );
- inTransaction( s -> {
- NonAnnotatedEntity retrievedEntity = s.find( NonAnnotatedEntity.class, persistedEntity.getId() );
- assertThat( retrievedEntity ).extracting( NonAnnotatedEntity::getName )
- .isEqualTo( persistedEntity.getName() );
- } );
- }
-
- public static class NonAnnotatedEntity {
- private long id;
-
- private String name;
-
- public NonAnnotatedEntity() {
- }
-
- public NonAnnotatedEntity(String name) {
- this.name = name;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/PrimeMinister.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/PrimeMinister.java
deleted file mode 100644
index f8aab6395743..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/PrimeMinister.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-import java.util.Set;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.Id;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToMany;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity
-public class PrimeMinister {
- private Integer id;
- private String name;
- private Government currentGovernment;
- private Set governments;
-
- @ManyToOne
- public Government getCurrentGovernment() {
- return currentGovernment;
- }
-
- public void setCurrentGovernment(Government currentGovernment) {
- this.currentGovernment = currentGovernment;
- }
-
- @Id
- @GeneratedValue
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @OneToMany(mappedBy = "primeMinister")
- public Set getGovernments() {
- return governments;
- }
-
- public void setGovernments(Set governments) {
- this.governments = governments;
- }
-
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/Sky.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/Sky.java
deleted file mode 100644
index 69054279fec8..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/Sky.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-import java.util.HashSet;
-import java.util.Set;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.Id;
-import jakarta.persistence.ManyToMany;
-import jakarta.persistence.ManyToOne;
-
-/**
- * @author Emmanuel Bernard
- */
-@Entity(name="EarthSky")
-public class Sky {
- private Integer id;
- private Set cloudTypes = new HashSet();
- private CloudType mainCloud;
-
- @ManyToMany
- public Set getCloudTypes() {
- return cloudTypes;
- }
-
- public void setCloudTypes(Set cloudTypes) {
- this.cloudTypes = cloudTypes;
- }
-
- @Id @GeneratedValue
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- @ManyToOne
- public CloudType getMainCloud() {
- return mainCloud;
- }
-
- public void setMainCloud(CloudType mainCloud) {
- this.mainCloud = mainCloud;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/Z.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/Z.java
deleted file mode 100644
index 653adf482c15..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/Z.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-
-
-/**
- * @author Emmanuel Bernard
- */
-public interface Z extends java.io.Serializable {
-public Integer getZId();
-
-public void setZId(Integer zId);
-
-public B getB();
-
-public void setB(B b);
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/ZImpl.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/ZImpl.java
deleted file mode 100644
index 9023f840f65f..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/hbm/ZImpl.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.annotations.xml.hbm;
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.Id;
-import jakarta.persistence.Inheritance;
-import jakarta.persistence.InheritanceType;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.Table;
-
-@Entity
-@Inheritance( strategy = InheritanceType.JOINED )
-@Table( name = "ENTITYZ" )
-public class ZImpl implements Z {
- private static final long serialVersionUID = 1L;
-
- private Integer zId = null;
- private B b = null;
-
- @Id
- @GeneratedValue
- @Column( name = "zID" )
- public Integer getZId() {
- return zId;
- }
-
- public void setZId(Integer zId) {
- this.zId = zId;
- }
-
- @ManyToOne( optional = false, targetEntity = BImpl.class, fetch = FetchType.LAZY )
- @JoinColumn( name = "bID", referencedColumnName = "bID")
- public B getB() {
- return b;
- }
-
- public void setB(B b) {
- this.b = b;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/AnyEagerHbmTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/AnyEagerHbmTest.java
deleted file mode 100644
index b4602a882f6c..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/AnyEagerHbmTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.any.hbm;
-
-import org.hibernate.Hibernate;
-import org.hibernate.stat.spi.StatisticsImplementor;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.hibernate.orm.test.any.annotations.IntegerProperty;
-import org.hibernate.orm.test.any.annotations.Property;
-import org.hibernate.orm.test.any.annotations.PropertySet;
-import org.hibernate.orm.test.any.annotations.StringProperty;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-@DomainModel(
- annotatedClasses = { StringProperty.class, IntegerProperty.class },
- xmlMappings = "org/hibernate/orm/test/any/hbm/AnyTestEagerPropertySet.hbm.xml"
-)
-@SessionFactory( generateStatistics = true )
-public class AnyEagerHbmTest {
- @BeforeEach
- public void createTestData(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> {
- final PropertySet propertySet = new PropertySet( "string" );
- final Property property = new StringProperty( "name", "Alex" );
- propertySet.setSomeProperty( property );
- session.persist( propertySet );
- }
- );
- }
-
- @AfterEach
- public void dropTestData(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> {
- session.createQuery( "delete StringProperty" ).executeUpdate();
- session.createQuery( "delete PropertySet" ).executeUpdate();
- }
- );
- }
-
- @Test
- public void testFetchEager(SessionFactoryScope scope) {
- final StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
- assertThat( statistics.isStatisticsEnabled(), is( true ) );
- statistics.clear();
-
- scope.inTransaction(
- session -> {
- final PropertySet result = session
- .createQuery( "from PropertySet", PropertySet.class )
- .uniqueResult();
-
- assertNotNull( result );
- assertNotNull( result.getSomeProperty() );
- assertThat( Hibernate.isInitialized( result.getSomeProperty() ), is( true ) );
-
- assertThat( statistics.getPrepareStatementCount(), is(2L ) );
-
- assertTrue( result.getSomeProperty() instanceof StringProperty );
- assertEquals( "Alex", result.getSomeProperty().asString() );
-
- assertThat( statistics.getPrepareStatementCount(), is(2L ) );
- }
- );
-
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/AnyLazyHbmTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/AnyLazyHbmTest.java
deleted file mode 100644
index 49f0e1472712..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/AnyLazyHbmTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.any.hbm;
-
-import org.hibernate.Hibernate;
-import org.hibernate.stat.spi.StatisticsImplementor;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.hibernate.orm.test.any.annotations.IntegerProperty;
-import org.hibernate.orm.test.any.annotations.LazyPropertySet;
-import org.hibernate.orm.test.any.annotations.Property;
-import org.hibernate.orm.test.any.annotations.StringProperty;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-
-@DomainModel(
- annotatedClasses = { StringProperty.class, IntegerProperty.class },
- xmlMappings = "org/hibernate/orm/test/any/hbm/AnyTestLazyPropertySet.hbm.xml"
-)
-@SessionFactory( generateStatistics = true )
-public class AnyLazyHbmTest {
-
- @BeforeEach
- public void prepareTestData(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> {
- LazyPropertySet set = new LazyPropertySet( "string" );
- Property property = new StringProperty( "name", "Alex" );
- set.setSomeProperty( property );
- session.persist( set );
- }
- );
- }
-
- @AfterEach
- public void dropTestData(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> {
- session.createQuery( "delete StringProperty" ).executeUpdate();
- session.createQuery( "delete LazyPropertySet" ).executeUpdate();
- }
- );
- }
-
- @Test
- public void testFetchLazy(SessionFactoryScope scope) {
- final StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
- assertThat( statistics.isStatisticsEnabled(), is( true ) );
- statistics.clear();
-
- scope.inTransaction(
- session -> {
- final LazyPropertySet result = session
- .createQuery( "select s from LazyPropertySet s where name = :name", LazyPropertySet.class )
- .setParameter( "name", "string" )
- .getSingleResult();
-
- assertNotNull( result );
- assertNotNull( result.getSomeProperty() );
- assertThat( Hibernate.isInitialized( result.getSomeProperty() ), is( false ) );
-
- assertThat( statistics.getPrepareStatementCount(), is(1L ) );
-
- assertTrue( result.getSomeProperty() instanceof StringProperty );
- assertEquals( "Alex", result.getSomeProperty().asString() );
-
- assertThat( statistics.getPrepareStatementCount(), is(2L ) );
- }
- );
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/Address.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/Address.java
similarity index 92%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/Address.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/Address.java
index ae28b6584c05..1e2a734b1586 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/Address.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/Address.java
@@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
-package org.hibernate.orm.test.any.hbm;
+package org.hibernate.orm.test.any.xml;
import java.util.HashSet;
import java.util.Set;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/AnyContainer.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/AnyContainer.java
new file mode 100644
index 000000000000..67e2bcaf0355
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/AnyContainer.java
@@ -0,0 +1,57 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.any.xml;
+
+import java.util.Map;
+
+/**
+ * @author Steve Ebersole
+ */
+public class AnyContainer {
+ private Integer id;
+ private String name;
+ private PropertyValue someSpecificProperty;
+ private Map generalProperties;
+
+ public AnyContainer() {
+ }
+
+ public AnyContainer(Integer id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public PropertyValue getSomeSpecificProperty() {
+ return someSpecificProperty;
+ }
+
+ public void setSomeSpecificProperty(PropertyValue someSpecificProperty) {
+ this.someSpecificProperty = someSpecificProperty;
+ }
+
+ public Map getGeneralProperties() {
+ return generalProperties;
+ }
+
+ public void setGeneralProperties(Map generalProperties) {
+ this.generalProperties = generalProperties;
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/AnyTypeTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/AnyTypeTest.java
similarity index 92%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/AnyTypeTest.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/AnyTypeTest.java
index aced9ec83c71..777dc1d26978 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/AnyTypeTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/AnyTypeTest.java
@@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
-package org.hibernate.orm.test.any.hbm;
+package org.hibernate.orm.test.any.xml;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.query.SemanticException;
@@ -24,9 +24,10 @@
/**
* @author Steve Ebersole
*/
+@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey(value = "HHH-1663")
@ServiceRegistry( settings = @Setting( name = AvailableSettings.USE_SECOND_LEVEL_CACHE, value = "false" ) )
-@DomainModel( xmlMappings = "org/hibernate/orm/test/any/hbm/Person.hbm.xml" )
+@DomainModel( xmlMappings = "org/hibernate/orm/test/any/xml/Person.xml")
@SessionFactory
public class AnyTypeTest {
@@ -46,9 +47,7 @@ public void createTestData(SessionFactoryScope scope) {
@AfterEach
public void dropTestData(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> session.createQuery( "delete Person" ).executeUpdate()
- );
+ scope.dropData();
}
@Test
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/ComplexPropertyValue.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/ComplexPropertyValue.java
similarity index 95%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/ComplexPropertyValue.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/ComplexPropertyValue.java
index fd031d362689..32fe23558951 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/ComplexPropertyValue.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/ComplexPropertyValue.java
@@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
-package org.hibernate.orm.test.any.hbm;
+package org.hibernate.orm.test.any.xml;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/IntegerPropertyValue.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/IntegerPropertyValue.java
similarity index 94%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/IntegerPropertyValue.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/IntegerPropertyValue.java
index 8090c52ff204..7f1210fc79cf 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/IntegerPropertyValue.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/IntegerPropertyValue.java
@@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
-package org.hibernate.orm.test.any.hbm;
+package org.hibernate.orm.test.any.xml;
/**
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/entityname/Address.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/Mapper.java
similarity index 54%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/entityname/Address.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/Mapper.java
index f75636ff93a4..b34286a2f8b0 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/entityname/Address.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/Mapper.java
@@ -2,12 +2,15 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
-package org.hibernate.orm.test.boot.models.hbm.entityname;
+package org.hibernate.orm.test.any.xml;
+
+import java.util.Map;
/**
* @author Steve Ebersole
*/
-public class Address {
+public class Mapper {
private Integer id;
- private String txt;
+ private String name;
+ private Map stuff;
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/Person.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/Person.java
similarity index 93%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/Person.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/Person.java
index 5435765846ba..4b2eea077f01 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/Person.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/Person.java
@@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
-package org.hibernate.orm.test.any.hbm;
+package org.hibernate.orm.test.any.xml;
/**
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/PropertySet.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/PropertySet.java
similarity index 93%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/PropertySet.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/PropertySet.java
index 6f597abc886d..ce819fa2014b 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/PropertySet.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/PropertySet.java
@@ -2,13 +2,11 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
-package org.hibernate.orm.test.any.hbm;
+package org.hibernate.orm.test.any.xml;
import java.util.HashMap;
import java.util.Map;
/**
- * todo: describe PropertySet
- *
* @author Steve Ebersole
*/
public class PropertySet {
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/PropertyValue.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/PropertyValue.java
similarity index 85%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/PropertyValue.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/PropertyValue.java
index 9d749ab38fd2..b11e98766202 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/PropertyValue.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/PropertyValue.java
@@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
-package org.hibernate.orm.test.any.hbm;
+package org.hibernate.orm.test.any.xml;
/**
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/StringPropertyValue.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/StringPropertyValue.java
similarity index 87%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/StringPropertyValue.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/StringPropertyValue.java
index c936d520eb06..4ec761927591 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/any/hbm/StringPropertyValue.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml/StringPropertyValue.java
@@ -2,12 +2,9 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
-package org.hibernate.orm.test.any.hbm;
-
+package org.hibernate.orm.test.any.xml;
/**
- * todo: describe StringPropertyValue
- *
* @author Steve Ebersole
*/
public class StringPropertyValue implements PropertyValue {
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/AnyEagerXmlTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/AnyEagerXmlTest.java
new file mode 100644
index 000000000000..d8ff6976469a
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/AnyEagerXmlTest.java
@@ -0,0 +1,90 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.any.xml2;
+
+import org.hibernate.Hibernate;
+import org.hibernate.testing.jdbc.SQLStatementInspector;
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@SuppressWarnings("JUnitMalformedDeclaration")
+@DomainModel( xmlMappings = {
+ "org/hibernate/orm/test/any/xml2/NamedAnyContainerEager.xml",
+ "org/hibernate/orm/test/any/xml2/NamedProperties.xml",
+} )
+@SessionFactory(useCollectingStatementInspector = true)
+public class AnyEagerXmlTest {
+ @AfterEach
+ public void dropTestData(SessionFactoryScope scope) {
+ scope.dropData();
+ }
+
+ @Test
+ public void testFetchEagerAny(SessionFactoryScope scope) {
+ final SQLStatementInspector sqlCollector = scope.getCollectingStatementInspector();
+
+ scope.inTransaction( (session) -> {
+ final NamedAnyContainer container = new NamedAnyContainer( 1, "stuff" );
+ final NamedProperty property = new NamedStringProperty( 1, "name", "Alex" );
+ container.setSpecificProperty( property );
+ session.persist( container );
+ } );
+
+ scope.inTransaction( (session) -> {
+ sqlCollector.clear();
+ final NamedAnyContainer result = session
+ .createQuery( "from NamedAnyContainer", NamedAnyContainer.class )
+ .uniqueResult();
+
+ assertThat( sqlCollector.getSqlQueries() ).hasSize( 3 );
+
+ assertThat( result ).isNotNull();
+ assertThat( result.getSpecificProperty() ).isNotNull();
+ assertThat( Hibernate.isInitialized( result.getSpecificProperty() ) ).isTrue();
+
+ assertThat( result.getSpecificProperty() ).isInstanceOf( NamedStringProperty.class );
+ assertThat( result.getSpecificProperty().asString() ).isEqualTo( "Alex" );
+
+ assertThat( sqlCollector.getSqlQueries() ).hasSize( 3 );
+ } );
+ }
+
+ @Test
+ public void testFetchEagerManyToAny(SessionFactoryScope scope) {
+ final SQLStatementInspector sqlCollector = scope.getCollectingStatementInspector();
+
+ scope.inTransaction( (session) -> {
+ final NamedAnyContainer container = new NamedAnyContainer( 1, "stuff" );
+ container.addGeneralProperty( new NamedStringProperty( 1, "name", "Alex" ) );
+ container.addGeneralProperty( new NamedIntegerProperty( 1, "age", 23 ) );
+ session.persist( container );
+ } );
+
+ scope.inTransaction( (session) -> {
+ sqlCollector.clear();
+ final NamedAnyContainer result = session
+ .createQuery( "from NamedAnyContainer", NamedAnyContainer.class )
+ .uniqueResult();
+
+ assertThat( sqlCollector.getSqlQueries() ).hasSize( 4 );
+
+ assertThat( result ).isNotNull();
+ assertThat( result.getSpecificProperty() ).isNull();
+
+ assertThat( result.getGeneralProperties() ).isNotNull();
+ assertThat( Hibernate.isInitialized( result.getGeneralProperties() ) ).isTrue();
+ assertThat( result.getGeneralProperties() ).hasSize( 2 );
+ assertThat( result.getGeneralProperties().stream().map( NamedProperty::getName ) )
+ .containsOnly( "name", "age" );
+
+ assertThat( sqlCollector.getSqlQueries() ).hasSize( 4 );
+ } );
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/AnyLazyXmlTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/AnyLazyXmlTest.java
new file mode 100644
index 000000000000..0b4cd6cca0e7
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/AnyLazyXmlTest.java
@@ -0,0 +1,89 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.any.xml2;
+
+import org.assertj.core.api.Assertions;
+import org.hibernate.Hibernate;
+import org.hibernate.testing.jdbc.SQLStatementInspector;
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+@SuppressWarnings("JUnitMalformedDeclaration")
+@DomainModel( xmlMappings = {
+ "org/hibernate/orm/test/any/xml2/NamedAnyContainerLazy.xml",
+ "org/hibernate/orm/test/any/xml2/NamedProperties.xml",
+} )
+@SessionFactory( generateStatistics = true )
+public class AnyLazyXmlTest {
+ @AfterEach
+ public void dropTestData(SessionFactoryScope scope) {
+ scope.dropData();
+ }
+
+ @Test
+ public void testFetchEagerAny(SessionFactoryScope scope) {
+ final SQLStatementInspector sqlCollector = scope.getCollectingStatementInspector();
+
+ scope.inTransaction( (session) -> {
+ final NamedAnyContainer container = new NamedAnyContainer( 1, "stuff" );
+ final NamedProperty property = new NamedStringProperty( 1, "name", "Alex" );
+ container.setSpecificProperty( property );
+ session.persist( container );
+ } );
+
+ scope.inTransaction( (session) -> {
+ sqlCollector.clear();
+ final NamedAnyContainer result = session
+ .createQuery( "from NamedAnyContainer", NamedAnyContainer.class )
+ .uniqueResult();
+
+ Assertions.assertThat( sqlCollector.getSqlQueries() ).hasSize( 1 );
+
+ Assertions.assertThat( result ).isNotNull();
+ Assertions.assertThat( result.getSpecificProperty() ).isNotNull();
+ Assertions.assertThat( Hibernate.isInitialized( result.getSpecificProperty() ) ).isFalse();
+
+ Assertions.assertThat( result.getSpecificProperty() ).isInstanceOf( NamedStringProperty.class );
+ Assertions.assertThat( result.getSpecificProperty().asString() ).isEqualTo( "Alex" );
+
+ Assertions.assertThat( sqlCollector.getSqlQueries() ).hasSize( 2 );
+ } );
+ }
+
+ @Test
+ public void testFetchEagerManyToAny(SessionFactoryScope scope) {
+ final SQLStatementInspector sqlCollector = scope.getCollectingStatementInspector();
+
+ scope.inTransaction( (session) -> {
+ final NamedAnyContainer container = new NamedAnyContainer( 1, "stuff" );
+ container.addGeneralProperty( new NamedStringProperty( 1, "name", "Alex" ) );
+ container.addGeneralProperty( new NamedIntegerProperty( 1, "age", 23 ) );
+ session.persist( container );
+ } );
+
+ scope.inTransaction( (session) -> {
+ sqlCollector.clear();
+ final NamedAnyContainer result = session
+ .createQuery( "from NamedAnyContainer", NamedAnyContainer.class )
+ .uniqueResult();
+
+ Assertions.assertThat( sqlCollector.getSqlQueries() ).hasSize( 1 );
+
+ Assertions.assertThat( result ).isNotNull();
+ Assertions.assertThat( result.getSpecificProperty() ).isNull();
+
+ Assertions.assertThat( result.getGeneralProperties() ).isNotNull();
+ Assertions.assertThat( Hibernate.isInitialized( result.getGeneralProperties() ) ).isFalse();
+ Assertions.assertThat( result.getGeneralProperties() ).hasSize( 2 );
+ Assertions.assertThat( result.getGeneralProperties().stream().map( NamedProperty::getName ) )
+ .containsOnly( "name", "age" );
+
+ Assertions.assertThat( sqlCollector.getSqlQueries() ).hasSize( 4 );
+ } );
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/NamedAnyContainer.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/NamedAnyContainer.java
new file mode 100644
index 000000000000..62962418a831
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/NamedAnyContainer.java
@@ -0,0 +1,65 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.any.xml2;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+/**
+ * @author Steve Ebersole
+ */
+public class NamedAnyContainer {
+ private Integer id;
+ private String name;
+ private NamedProperty specificProperty;
+ private Set generalProperties;
+
+ public NamedAnyContainer() {
+ }
+
+ public NamedAnyContainer(Integer id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public NamedProperty getSpecificProperty() {
+ return specificProperty;
+ }
+
+ public void setSpecificProperty(NamedProperty specificProperty) {
+ this.specificProperty = specificProperty;
+ }
+
+ public Set getGeneralProperties() {
+ return generalProperties;
+ }
+
+ public void setGeneralProperties(Set generalProperties) {
+ this.generalProperties = generalProperties;
+ }
+
+ public void addGeneralProperty(NamedProperty property) {
+ if ( generalProperties == null ) {
+ generalProperties = new LinkedHashSet<>();
+ }
+ generalProperties.add( property );
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/NamedIntegerProperty.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/NamedIntegerProperty.java
new file mode 100644
index 000000000000..5b63c5064514
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/NamedIntegerProperty.java
@@ -0,0 +1,61 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.any.xml2;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+
+@Entity
+@Table(name="int_property")
+public class NamedIntegerProperty implements NamedProperty {
+ private Integer id;
+ private String name;
+ private Integer value;
+
+ public NamedIntegerProperty() {
+ super();
+ }
+
+ public NamedIntegerProperty(int id, String name, Integer value) {
+ super();
+ this.id = id;
+ this.name = name;
+ this.value = value;
+ }
+
+ public String asString() {
+ return Integer.toString(value);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ @Id
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ @Column(name = "`value`")
+ public Integer getValue() {
+ return value;
+ }
+
+ public void setValue(Integer value) {
+ this.value = value;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/NamedProperty.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/NamedProperty.java
new file mode 100644
index 000000000000..29173257fc25
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/NamedProperty.java
@@ -0,0 +1,10 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.any.xml2;
+
+public interface NamedProperty {
+ String getName();
+ String asString();
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/NamedStringProperty.java b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/NamedStringProperty.java
new file mode 100644
index 000000000000..29979be604de
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/any/xml2/NamedStringProperty.java
@@ -0,0 +1,59 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.any.xml2;
+
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Table;
+
+@Entity
+@Table(name="string_property")
+public class NamedStringProperty implements NamedProperty {
+ private Integer id;
+ private String name;
+ private String value;
+
+ public NamedStringProperty() {
+ super();
+ }
+
+ public NamedStringProperty(int id, String name, String value) {
+ super();
+ this.id = id;
+ this.name = name;
+ this.value = value;
+ }
+
+ @Id
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String asString() {
+ return value;
+ }
+
+ @Column(name = "`value`")
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/array/ArrayTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/array/ArrayTest.java
index d84faf08a5ac..f2e22f988db8 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/array/ArrayTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/array/ArrayTest.java
@@ -4,9 +4,7 @@
*/
package org.hibernate.orm.test.array;
-import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.RequiresDialectFeature;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test;
@@ -17,10 +15,8 @@
/**
* @author Emmanuel Bernard
*/
-@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsNoColumnInsert.class)
-@DomainModel(
- xmlMappings = "org/hibernate/orm/test/array/A.hbm.xml"
-)
+@SuppressWarnings("JUnitMalformedDeclaration")
+@DomainModel(xmlMappings = "org/hibernate/orm/test/array/A.xml")
@SessionFactory
public class ArrayTest {
@@ -37,7 +33,7 @@ public void testArrayJoinFetch(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
- A retrieved = session.get( A.class, a.getId() );
+ A retrieved = session.find( A.class, a.getId() );
assertNotNull( retrieved );
assertNotNull( retrieved.getBs() );
assertEquals( 1, retrieved.getBs().length );
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchTest.java
index 1609ebbc1372..cbca3791f65a 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchTest.java
@@ -4,18 +4,19 @@
*/
package org.hibernate.orm.test.batch;
-import java.math.BigDecimal;
-
import org.hibernate.CacheMode;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.cfg.Environment;
+import org.hibernate.cfg.AvailableSettings;
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.ServiceRegistry;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.hibernate.testing.orm.junit.Setting;
+import org.junit.jupiter.api.Test;
-import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
-import org.junit.Test;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
/**
* This is how to do batch processing in Hibernate. Remember to enable JDBC batch updates, or this test will take a
@@ -23,103 +24,89 @@
*
* @author Gavin King
*/
-public class BatchTest extends BaseCoreFunctionalTestCase {
-
- @Override
- protected String getBaseForMappings() {
- return "org/hibernate/orm/test/";
- }
-
- @Override
- public String[] getMappings() {
- return new String[] { "batch/DataPoint.hbm.xml" };
- }
-
- @Override
- public void configure(Configuration cfg) {
- cfg.setProperty( Environment.STATEMENT_BATCH_SIZE, 20 );
- }
+@SuppressWarnings("JUnitMalformedDeclaration")
+@ServiceRegistry(settings = {
+ @Setting(name= AvailableSettings.STATEMENT_BATCH_SIZE, value = "20")
+})
+@DomainModel(xmlMappings = "org/hibernate/orm/test/batch/DataPoint.xml")
+@SessionFactory
+public class BatchTest {
@Test
- public void testBatchInsertUpdate() {
+ public void testBatchInsertUpdate(SessionFactoryScope factoryScope) {
long start = System.currentTimeMillis();
final int N = 5000; //26 secs with batch flush, 26 without
//final int N = 100000; //53 secs with batch flush, OOME without
//final int N = 250000; //137 secs with batch flush, OOME without
- int batchSize = sessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
- doBatchInsertUpdate( N, batchSize );
+ int batchSize = factoryScope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
+ doBatchInsertUpdate( N, batchSize, factoryScope );
System.out.println( System.currentTimeMillis() - start );
}
@Test
- public void testBatchInsertUpdateSizeEqJdbcBatchSize() {
- int batchSize = sessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
- doBatchInsertUpdate( 50, batchSize );
+ public void testBatchInsertUpdateSizeEqJdbcBatchSize(SessionFactoryScope factoryScope) {
+ int batchSize = factoryScope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
+ doBatchInsertUpdate( 50, batchSize, factoryScope );
}
@Test
- public void testBatchInsertUpdateSizeLtJdbcBatchSize() {
- int batchSize = sessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
- doBatchInsertUpdate( 50, batchSize - 1 );
+ public void testBatchInsertUpdateSizeLtJdbcBatchSize(SessionFactoryScope factoryScope) {
+ int batchSize = factoryScope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
+ doBatchInsertUpdate( 50, batchSize - 1, factoryScope );
}
@Test
- public void testBatchInsertUpdateSizeGtJdbcBatchSize() {
- int batchSize = sessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
- doBatchInsertUpdate( 50, batchSize + 1 );
+ public void testBatchInsertUpdateSizeGtJdbcBatchSize(SessionFactoryScope factoryScope) {
+ int batchSize = factoryScope.getSessionFactory().getSessionFactoryOptions().getJdbcBatchSize();
+ doBatchInsertUpdate( 50, batchSize + 1, factoryScope );
}
- public void doBatchInsertUpdate(int nEntities, int nBeforeFlush) {
- Session s = openSession();
- s.setCacheMode( CacheMode.IGNORE );
- Transaction t = s.beginTransaction();
- for ( int i = 0; i < nEntities; i++ ) {
- DataPoint dp = new DataPoint();
- dp.setX( new BigDecimal( i * 0.1d ).setScale( 19, BigDecimal.ROUND_DOWN ) );
- dp.setY( new BigDecimal( Math.cos( dp.getX().doubleValue() ) ).setScale( 19, BigDecimal.ROUND_DOWN ) );
- s.persist( dp );
- if ( ( i + 1 ) % nBeforeFlush == 0 ) {
- s.flush();
- s.clear();
+ public void doBatchInsertUpdate(int nEntities, int nBeforeFlush, SessionFactoryScope factoryScope) {
+ factoryScope.inTransaction( (session) -> {
+ session.setCacheMode( CacheMode.IGNORE );
+ for ( int i = 0; i < nEntities; i++ ) {
+ DataPoint dp = new DataPoint();
+ dp.setX( new BigDecimal( i * 0.1d ).setScale( 19, RoundingMode.DOWN ) );
+ dp.setY( BigDecimal.valueOf( Math.cos( dp.getX().doubleValue() ) ).setScale( 19, RoundingMode.DOWN ) );
+ session.persist( dp );
+ if ( ( i + 1 ) % nBeforeFlush == 0 ) {
+ session.flush();
+ session.clear();
+ }
}
- }
- t.commit();
- s.close();
+ } );
- s = openSession();
- s.setCacheMode( CacheMode.IGNORE );
- t = s.beginTransaction();
- int i = 0;
- try (ScrollableResults sr = s.createQuery( "from DataPoint dp order by dp.x asc" )
- .scroll( ScrollMode.FORWARD_ONLY )) {
- while ( sr.next() ) {
- DataPoint dp = (DataPoint) sr.get();
- dp.setDescription( "done!" );
- if ( ++i % nBeforeFlush == 0 ) {
- s.flush();
- s.clear();
+ factoryScope.inTransaction( (session) -> {
+ session.setCacheMode( CacheMode.IGNORE );
+ int i = 0;
+ try (ScrollableResults sr = session.createQuery( "from DataPoint dp order by dp.x asc" )
+ .scroll( ScrollMode.FORWARD_ONLY )) {
+ while ( sr.next() ) {
+ DataPoint dp = (DataPoint) sr.get();
+ dp.setDescription( "done!" );
+ if ( ++i % nBeforeFlush == 0 ) {
+ session.flush();
+ session.clear();
+ }
}
}
- }
- t.commit();
- s.close();
+ } );
+
+ factoryScope.inTransaction( (session) -> {
+ session.setCacheMode( CacheMode.IGNORE );
+ int i = 0;
- s = openSession();
- s.setCacheMode( CacheMode.IGNORE );
- t = s.beginTransaction();
- i = 0;
- try (ScrollableResults sr = s.createQuery( "from DataPoint dp order by dp.x asc" )
- .scroll( ScrollMode.FORWARD_ONLY )) {
- while ( sr.next() ) {
- DataPoint dp = (DataPoint) sr.get();
- s.remove( dp );
- if ( ++i % nBeforeFlush == 0 ) {
- s.flush();
- s.clear();
+ try (ScrollableResults sr = session.createQuery( "from DataPoint dp order by dp.x asc" )
+ .scroll( ScrollMode.FORWARD_ONLY )) {
+ while ( sr.next() ) {
+ DataPoint dp = (DataPoint) sr.get();
+ session.remove( dp );
+ if ( ++i % nBeforeFlush == 0 ) {
+ session.flush();
+ session.clear();
+ }
}
}
- }
- t.commit();
- s.close();
+ } );
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/BasicComposition.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/BasicComposition.java
deleted file mode 100644
index 2df79f3a5d79..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/BasicComposition.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.jaxb.hbm;
-
-/**
- * @author Steve Ebersole
- */
-public class BasicComposition {
- private String part1;
- private String part2;
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/BasicEntity.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/BasicEntity.java
deleted file mode 100644
index e206c8d5403b..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/BasicEntity.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.jaxb.hbm;
-
-import java.util.List;
-
-/**
- * @author Steve Ebersole
- */
-public class BasicEntity {
- private Integer id;
- private String name;
- private BasicComposition composition;
- private BasicEntity another;
- private List others;
-
- private BasicEntity() {
- // for Hibernate use
- }
-
- public BasicEntity(Integer id, String name) {
- this.id = id;
- this.name = name;
- }
-
- public Integer getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/BasicTransformationTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/BasicTransformationTests.java
deleted file mode 100644
index f5ac010209a6..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/BasicTransformationTests.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.jaxb.hbm;
-
-import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddableImpl;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityImpl;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
-
-import org.hibernate.testing.orm.junit.Jira;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * @author Steve Ebersole
- */
-@SuppressWarnings("JUnitMalformedDeclaration")
-@ServiceRegistry
-public class BasicTransformationTests {
-
- @Test
- public void testBasicTransformation(ServiceRegistryScope scope) {
- final JaxbEntityMappingsImpl transformed = TransformationHelper.transform( "xml/jaxb/mapping/basic/hbm.xml", scope.getRegistry() );
-
- assertThat( transformed ).isNotNull();
-
- assertThat( transformed.getPackage() ).isEqualTo( "org.hibernate.orm.test.boot.jaxb.mapping" );
- assertThat( transformed.getCatalog() ).isNull();
- assertThat( transformed.getSchema() ).isNull();
- assertThat( transformed.getAccess() ).isNull();
- assertThat( transformed.getAttributeAccessor() ).isEqualTo( "property" );
- assertThat( transformed.getDefaultCascade() ).isEqualTo( "none" );
-
- assertThat( transformed.getEntities() ).hasSize( 1 );
- assertThat( transformed.getEmbeddables() ).hasSize( 0 );
-
- final JaxbEntityImpl ormEntity = transformed.getEntities().get( 0 );
- assertThat( ormEntity.getName() ).isNull();
- assertThat( ormEntity.getClazz() ).isEqualTo( "SimpleEntity" );
-
- assertThat( ormEntity.getAttributes().getIdAttributes() ).hasSize( 1 );
- assertThat( ormEntity.getAttributes().getBasicAttributes() ).hasSize( 1 );
- assertThat( ormEntity.getAttributes().getEmbeddedAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getOneToOneAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getManyToOneAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getAnyMappingAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getOneToManyAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getManyToManyAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getPluralAnyMappingAttributes() ).isEmpty();
-
- TransformationHelper.verifyTransformation( transformed );
- }
-
- @Test
- public void testBasicTransformation2(ServiceRegistryScope scope) {
- final JaxbEntityMappingsImpl transformed = TransformationHelper.transform( "mappings/hbm/basic.xml", scope.getRegistry() );
-
- assertThat( transformed ).isNotNull();
-
- assertThat( transformed.getPackage() ).isEqualTo( "org.hibernate.orm.test.boot.jaxb.hbm" );
- assertThat( transformed.getCatalog() ).isEqualTo( "the_catalog" );
- assertThat( transformed.getSchema() ).isEqualTo( "the_schema" );
- assertThat( transformed.getAccess() ).isNull();
- assertThat( transformed.getAttributeAccessor() ).isEqualTo( "field" );
- assertThat( transformed.getDefaultCascade() ).isEqualTo( "all" );
-
- assertThat( transformed.getEntities() ).hasSize( 1 );
- assertThat( transformed.getEmbeddables() ).hasSize( 1 );
-
- final JaxbEntityImpl ormEntity = transformed.getEntities().get( 0 );
- assertThat( ormEntity.getName() ).isNull();
- assertThat( ormEntity.getClazz() ).isEqualTo( "BasicEntity" );
-
- assertThat( ormEntity.getAttributes().getIdAttributes() ).hasSize( 1 );
- assertThat( ormEntity.getAttributes().getBasicAttributes() ).hasSize( 1 );
- assertThat( ormEntity.getAttributes().getEmbeddedAttributes() ).hasSize( 1 );
- assertThat( ormEntity.getAttributes().getOneToOneAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getManyToOneAttributes() ).hasSize(1 );
- assertThat( ormEntity.getAttributes().getAnyMappingAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getOneToManyAttributes() ).hasSize( 1 );
- assertThat( ormEntity.getAttributes().getManyToManyAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getPluralAnyMappingAttributes() ).isEmpty();
-
- final JaxbEmbeddableImpl jaxbEmbeddable = transformed.getEmbeddables().get( 0 );
- assertThat( jaxbEmbeddable.isMetadataComplete() ).isTrue();
- assertThat( jaxbEmbeddable.getName() ).isEqualTo( "org.hibernate.orm.test.boot.jaxb.hbm.BasicComposition" );
- assertThat( jaxbEmbeddable.getClazz() ).isEqualTo( "org.hibernate.orm.test.boot.jaxb.hbm.BasicComposition" );
-
- TransformationHelper.verifyTransformation( transformed );
- }
-
- @Test
- @Jira( "https://hibernate.atlassian.net/browse/HHH-16822" )
- public void testSimpleTransformation(ServiceRegistryScope scope) {
- final JaxbEntityMappingsImpl transformed = TransformationHelper.transform( "mappings/hbm/simple.xml", scope.getRegistry() );
-
- assertThat( transformed ).isNotNull();
- assertThat( transformed.getEntities() ).hasSize( 1 );
- assertThat( transformed.getEmbeddables() ).hasSize( 0 );
-
- final JaxbEntityImpl ormEntity = transformed.getEntities().get( 0 );
- assertThat( ormEntity.getName() ).isEqualTo( "SimpleEntity" );
- assertThat( ormEntity.getClazz() ).isNull();
-
- assertThat( ormEntity.getAttributes().getIdAttributes() ).hasSize( 1 );
- assertThat( ormEntity.getAttributes().getBasicAttributes() ).hasSize( 1 );
- assertThat( ormEntity.getAttributes().getEmbeddedAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getOneToOneAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getManyToOneAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getAnyMappingAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getOneToManyAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getManyToManyAttributes() ).isEmpty();
- assertThat( ormEntity.getAttributes().getPluralAnyMappingAttributes() ).isEmpty();
-
- TransformationHelper.verifyTransformation( transformed );
- }
-
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/TransformationHelper.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/TransformationHelper.java
deleted file mode 100644
index 85d97a2a772d..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/TransformationHelper.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.jaxb.hbm;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.List;
-
-import javax.xml.stream.XMLEventFactory;
-import javax.xml.stream.XMLEventReader;
-
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.boot.jaxb.Origin;
-import org.hibernate.boot.jaxb.SourceType;
-import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
-import org.hibernate.boot.jaxb.hbm.transform.HbmXmlTransformer;
-import org.hibernate.boot.jaxb.hbm.transform.UnsupportedFeatureHandling;
-import org.hibernate.boot.jaxb.internal.stax.HbmEventReader;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
-import org.hibernate.boot.jaxb.spi.Binding;
-import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
-import org.hibernate.boot.spi.MetadataImplementor;
-import org.hibernate.boot.xsd.MappingXsdSupport;
-import org.hibernate.orm.test.boot.jaxb.JaxbHelper;
-import org.hibernate.service.ServiceRegistry;
-
-import jakarta.xml.bind.JAXBContext;
-import jakarta.xml.bind.JAXBException;
-import jakarta.xml.bind.Marshaller;
-import jakarta.xml.bind.Unmarshaller;
-
-import static java.util.Collections.singletonList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.hibernate.orm.test.boot.jaxb.JaxbHelper.withStaxEventReader;
-
-/**
- * @author Steve Ebersole
- */
-public class TransformationHelper {
- public static JaxbEntityMappingsImpl transform(String resourceName, ServiceRegistry serviceRegistry) {
- final ClassLoaderService cls = serviceRegistry.requireService( ClassLoaderService.class );
- try ( final InputStream inputStream = cls.locateResourceStream( resourceName ) ) {
- return withStaxEventReader( inputStream, cls, (staxEventReader) -> {
- final XMLEventReader reader = new HbmEventReader( staxEventReader, XMLEventFactory.newInstance() );
-
- try {
- final JAXBContext jaxbCtx = JAXBContext.newInstance( JaxbHbmHibernateMapping.class );
- final JaxbHbmHibernateMapping hbmMapping = JaxbHelper.VALIDATING.jaxb(
- reader,
- MappingXsdSupport.hbmXml.getSchema(),
- jaxbCtx
- );
- assertThat( hbmMapping ).isNotNull();
- assertThat( hbmMapping.getClazz() ).hasSize( 1 );
-
- final MetadataImplementor metadata = (MetadataImplementor) new MetadataSources( serviceRegistry ).addHbmXmlBinding( new Binding<>(
- hbmMapping,
- new Origin( SourceType.RESOURCE, resourceName )
- ) ).buildMetadata();
- final List> transformed = HbmXmlTransformer.transform(
- singletonList( new Binding<>( hbmMapping, new Origin( SourceType.RESOURCE, resourceName ) ) ),
- metadata,
- UnsupportedFeatureHandling.ERROR
- );
-
- return transformed.get(0).getRoot();
- }
- catch (JAXBException e) {
- throw new RuntimeException( "Error during JAXB processing", e );
- }
- } );
- }
- catch (IOException e) {
- throw new RuntimeException( "Error accessing mapping file", e );
- }
- }
-
- /**
- * Verify correctness of the transformed mapping by marshalling and unmarshalling it
- * using the JaxbEntityMappings JAXBContext
- */
- static void verifyTransformation(JaxbEntityMappingsImpl transformed) {
- try {
- final JAXBContext jaxbContext = JAXBContext.newInstance( JaxbEntityMappingsImpl.class );
- final Marshaller marshaller = jaxbContext.createMarshaller();
- final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
-
- final StringWriter stringWriter = new StringWriter();
- marshaller.marshal( transformed, stringWriter );
-
- final String transformedXml = stringWriter.toString();
-
- final StringReader stringReader = new StringReader( transformedXml );
- final JaxbEntityMappingsImpl unmarshalled = (JaxbEntityMappingsImpl) unmarshaller.unmarshal( stringReader );
-
- assertThat( unmarshalled ).isNotNull();
- }
- catch (JAXBException e) {
- throw new RuntimeException( "Unable to create JAXBContext for JaxbEntityMappings", e );
- }
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/internal/GenerationTimingConverterTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/internal/GenerationTimingConverterTest.java
deleted file mode 100644
index 4f3ca778e77b..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/internal/GenerationTimingConverterTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.jaxb.hbm.internal;
-
-import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmBasicAttributeType;
-import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
-import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType;
-import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSimpleIdType;
-
-import org.hibernate.testing.junit4.BaseUnitTestCase;
-import org.junit.Test;
-
-/**
- * @author Jean-François Boeuf
- */
-public class GenerationTimingConverterTest extends BaseUnitTestCase {
-
- @Test
- public void testMashallAttributeWithNullGenerationTiming()
- throws Exception {
- JaxbHbmHibernateMapping hm = new JaxbHbmHibernateMapping();
- JaxbHbmRootEntityType clazz = new JaxbHbmRootEntityType();
- JaxbHbmSimpleIdType id = new JaxbHbmSimpleIdType();
- JaxbHbmBasicAttributeType att = new JaxbHbmBasicAttributeType();
- att.setName( "attributeName" );
- clazz.getAttributes().add( att );
- clazz.setId( id );
- hm.getClazz().add( clazz );
-
- XmlBindingChecker.checkValidGeneration( hm );
- }
-
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/internal/RepresentationModeConverterTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/internal/RepresentationModeConverterTest.java
deleted file mode 100644
index ef6f36ca2818..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/internal/RepresentationModeConverterTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.jaxb.hbm.internal;
-
-import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
-import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType;
-import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSimpleIdType;
-
-import org.hibernate.testing.junit4.BaseUnitTestCase;
-import org.junit.Test;
-
-/**
- * @author Jean-François Boeuf
- */
-public class RepresentationModeConverterTest extends BaseUnitTestCase {
-
- @Test
- public void testMashallNullEntityMode() throws Exception {
- XmlBindingChecker.checkValidGeneration( generateXml() );
- }
-
-
- private JaxbHbmHibernateMapping generateXml() {
- JaxbHbmHibernateMapping hm = new JaxbHbmHibernateMapping();
- JaxbHbmRootEntityType clazz = new JaxbHbmRootEntityType();
- JaxbHbmSimpleIdType id = new JaxbHbmSimpleIdType();
- clazz.setId( id );
- hm.getClazz().add( clazz );
- return hm;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/internal/XmlBindingChecker.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/internal/XmlBindingChecker.java
deleted file mode 100644
index a04527dae08a..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/jaxb/hbm/internal/XmlBindingChecker.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.jaxb.hbm.internal;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-
-import jakarta.xml.bind.JAXBContext;
-import jakarta.xml.bind.Marshaller;
-
-import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
-import org.hibernate.boot.spi.XmlMappingBinderAccess;
-import org.hibernate.service.ServiceRegistry;
-
-import org.hibernate.testing.util.ServiceRegistryUtil;
-
-/**
- * @author Jean-François Boeuf
- */
-public class XmlBindingChecker {
-
- public static void checkValidGeneration(JaxbHbmHibernateMapping hbmMapping)
- throws Exception {
- JAXBContext jaxbContext = JAXBContext
- .newInstance( JaxbHbmHibernateMapping.class );
-
- Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
- jaxbMarshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, true );
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- jaxbMarshaller.marshal( hbmMapping, bos );
- ByteArrayInputStream is = new ByteArrayInputStream( bos.toByteArray() );
- try (ServiceRegistry sr = ServiceRegistryUtil.serviceRegistry()) {
- new XmlMappingBinderAccess( sr ).bind( is );
- }
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/foreigngenerator/ForeignGeneratorTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/foreigngenerator/ForeignGeneratorTests.java
similarity index 95%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/foreigngenerator/ForeignGeneratorTests.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/foreigngenerator/ForeignGeneratorTests.java
index 3bd621cfda13..f6104fc68241 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/foreigngenerator/ForeignGeneratorTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/foreigngenerator/ForeignGeneratorTests.java
@@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
-package org.hibernate.orm.test.boot.models.hbm.foreigngenerator;
+package org.hibernate.orm.test.boot.models.foreigngenerator;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.SessionFactory;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/foreigngenerator/Info.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/foreigngenerator/Info.java
similarity index 94%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/foreigngenerator/Info.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/foreigngenerator/Info.java
index b4075c24e02f..6cc9bf98d033 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/foreigngenerator/Info.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/foreigngenerator/Info.java
@@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
-package org.hibernate.orm.test.boot.models.hbm.foreigngenerator;
+package org.hibernate.orm.test.boot.models.foreigngenerator;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/foreigngenerator/Thing.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/foreigngenerator/Thing.java
similarity index 92%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/foreigngenerator/Thing.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/foreigngenerator/Thing.java
index b5a8f23deb97..4ad17be434dd 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/foreigngenerator/Thing.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/foreigngenerator/Thing.java
@@ -2,7 +2,7 @@
* SPDX-License-Identifier: Apache-2.0
* Copyright Red Hat Inc. and Hibernate Authors
*/
-package org.hibernate.orm.test.boot.models.hbm.foreigngenerator;
+package org.hibernate.orm.test.boot.models.foreigngenerator;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/_extends/ExtendsTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/_extends/ExtendsTests.java
index 236749937c69..aac2b4798e8b 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/_extends/ExtendsTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/_extends/ExtendsTests.java
@@ -4,15 +4,22 @@
*/
package org.hibernate.orm.test.boot.models.hbm._extends;
+import jakarta.persistence.InheritanceType;
+import org.hibernate.boot.jaxb.Origin;
+import org.hibernate.boot.jaxb.SourceType;
+import org.hibernate.boot.jaxb.internal.MappingBinder;
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityImpl;
import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappingsImpl;
-import org.hibernate.orm.test.boot.jaxb.hbm.TransformationHelper;
-
+import org.hibernate.boot.jaxb.spi.Binding;
+import org.hibernate.boot.jaxb.spi.JaxbBindableMappingDescriptor;
+import org.hibernate.boot.registry.StandardServiceRegistry;
+import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
import org.junit.jupiter.api.Test;
-import jakarta.persistence.InheritanceType;
+import java.io.IOException;
+import java.io.InputStream;
import static org.assertj.core.api.Assertions.assertThat;
@@ -22,24 +29,24 @@
@SuppressWarnings("JUnitMalformedDeclaration")
public class ExtendsTests {
- @ServiceRegistry()
- @Test
- void testDiscriminatedStructured(ServiceRegistryScope registryScope) {
- final JaxbEntityMappingsImpl transformed = TransformationHelper.transform(
- "mappings/models/hbm/extends/discriminated-structured.xml",
- registryScope.getRegistry()
- );
- verifyHierarchy( transformed, InheritanceType.SINGLE_TABLE );
- }
-
@ServiceRegistry()
@Test
void testDiscriminatedSeparated(ServiceRegistryScope registryScope) {
- final JaxbEntityMappingsImpl transformed = TransformationHelper.transform(
- "mappings/models/hbm/extends/discriminated-separate.xml",
- registryScope.getRegistry()
- );
- verifyHierarchy( transformed, InheritanceType.SINGLE_TABLE );
+ final StandardServiceRegistry serviceRegistry = registryScope.getRegistry();
+ final ClassLoaderService classLoaderService = serviceRegistry.requireService( ClassLoaderService.class );
+ final MappingBinder mappingBinder = new MappingBinder( serviceRegistry );
+ final String mappingName = "mappings/models/hbm/extends/discriminated-separate.xml";
+
+ try (InputStream stream = classLoaderService.locateResourceStream( mappingName )) {
+ final Binding binding = mappingBinder.bind(
+ stream,
+ new Origin( SourceType.RESOURCE, mappingName )
+ );
+ verifyHierarchy( (JaxbEntityMappingsImpl) binding.getRoot(), InheritanceType.SINGLE_TABLE );
+ }
+ catch (IOException e) {
+ throw new RuntimeException( e );
+ }
}
private void verifyHierarchy(JaxbEntityMappingsImpl transformed, InheritanceType inheritanceType) {
@@ -47,22 +54,22 @@ private void verifyHierarchy(JaxbEntityMappingsImpl transformed, InheritanceType
assertThat( transformed.getEntities() ).hasSize( 3 );
for ( JaxbEntityImpl jaxbEntity : transformed.getEntities() ) {
- if ( "org.hibernate.test.hbm._extends.Root".equals( jaxbEntity.getClazz() ) ) {
+ if ( "Root".equals( jaxbEntity.getName() ) ) {
assertThat( jaxbEntity.getInheritance() ).isNotNull();
assertThat( jaxbEntity.getInheritance().getStrategy() ).isEqualTo( inheritanceType );
assertThat( jaxbEntity.getExtends() ).isNull();
assertThat( jaxbEntity.getDiscriminatorColumn().getName() ).isEqualTo( "the_type" );
assertThat( jaxbEntity.getDiscriminatorValue() ).isEqualTo( "R" );
}
- else if ( "org.hibernate.test.hbm._extends.Branch".equals( jaxbEntity.getName() ) ) {
+ else if ( "Branch".equals( jaxbEntity.getName() ) ) {
assertThat( jaxbEntity.getInheritance() ).isNull();
assertThat( jaxbEntity.getDiscriminatorValue() ).isEqualTo( "B" );
- assertThat( jaxbEntity.getExtends() ).isEqualTo( "org.hibernate.test.hbm._extends.Root" );
+ assertThat( jaxbEntity.getExtends() ).isEqualTo( "Root" );
}
- else if ( "org.hibernate.test.hbm._extends.Leaf".equals( jaxbEntity.getName() ) ) {
+ else if ( "Leaf".equals( jaxbEntity.getName() ) ) {
assertThat( jaxbEntity.getInheritance() ).isNull();
assertThat( jaxbEntity.getDiscriminatorValue() ).isEqualTo( "L" );
- assertThat( jaxbEntity.getExtends() ).isEqualTo( "org.hibernate.test.hbm._extends.Branch" );
+ assertThat( jaxbEntity.getExtends() ).isEqualTo( "Branch" );
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/Category.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/Category.java
index daec3f5625c3..04211e3879f8 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/Category.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/Category.java
@@ -4,18 +4,11 @@
*/
package org.hibernate.orm.test.boot.models.hbm.collections.list;
-import jakarta.persistence.Embeddable;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
-
/**
* @author Steve Ebersole
*/
-@Embeddable
public class Category {
private String name;
- @ManyToOne
- @JoinColumn(name = "owner_fk")
private User owner;
public String getName() {
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/ListTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/ListTests.java
index 5c0538ba9fc6..786b28d278af 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/ListTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/ListTests.java
@@ -4,20 +4,15 @@
*/
package org.hibernate.orm.test.boot.models.hbm.collections.list;
-import org.hibernate.cfg.MappingSettings;
import org.hibernate.mapping.BasicValue;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.List;
import org.hibernate.mapping.ManyToOne;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
-import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value;
-
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -29,22 +24,8 @@
@SuppressWarnings("JUnitMalformedDeclaration")
public class ListTests {
@Test
- @DomainModel( xmlMappings = "mappings/models/hbm/list/hbm.xml" )
-
- void testHbmXml(DomainModelScope domainModelScope) {
- final PersistentClass rootBinding = domainModelScope.getDomainModel().getEntityBinding( Root.class.getName() );
- validateTags( rootBinding.getProperty( "tags" ) );
- validateCategories( rootBinding.getProperty( "categories" ) );
- Property admins = rootBinding.getProperty( "admins" );
- Table collectionTable = ( (List) admins.getValue() ).getCollectionTable();
-// collectionTable.getColumns().
- Property admins2 = rootBinding.getProperty( "admins2" );
- }
-
- @Test
- @ServiceRegistry( settings = @Setting( name = MappingSettings.TRANSFORM_HBM_XML, value = "true" ) )
- @DomainModel( xmlMappings = "mappings/models/hbm/list/hbm.xml" )
- void testTransformation(DomainModelScope domainModelScope) {
+ @DomainModel( xmlMappings = "mappings/models/hbm/list/mapping.xml" )
+ void testXml(DomainModelScope domainModelScope) {
final PersistentClass rootBinding = domainModelScope.getDomainModel().getEntityBinding( Root.class.getName() );
validateTags( rootBinding.getProperty( "tags" ) );
validateCategories( rootBinding.getProperty( "categories" ) );
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/Root.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/Root.java
index 5aa85e9d858e..c0f056efae09 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/Root.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/Root.java
@@ -6,34 +6,15 @@
import java.util.List;
-import jakarta.persistence.CollectionTable;
-import jakarta.persistence.ElementCollection;
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-import jakarta.persistence.Basic;
-import jakarta.persistence.ManyToMany;
-import jakarta.persistence.OrderColumn;
-
/**
* @author Steve Ebersole
*/
-@Entity
public class Root {
- @Id
private Integer id;
- @Basic
private String name;
- @ElementCollection
private List tags;
- @ElementCollection
- @CollectionTable(name="root_categories")
- @OrderColumn(name = "position")
private List categories;
- @ManyToMany
- @CollectionTable(name="root_admins")
private List admins;
- @ManyToMany
- @CollectionTable(name="root_admins_2")
private List admins2;
@@ -45,52 +26,4 @@ public Root(Integer id, String name) {
this.id = id;
this.name = name;
}
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List getTags() {
- return tags;
- }
-
- public void setTags(List tags) {
- this.tags = tags;
- }
-
- public List getCategories() {
- return categories;
- }
-
- public void setCategories(List categories) {
- this.categories = categories;
- }
-
- public List getAdmins() {
- return admins;
- }
-
- public void setAdmins(List admins) {
- this.admins = admins;
- }
-
- public List getAdmins2() {
- return admins2;
- }
-
- public void setAdmins2(List admins2) {
- this.admins2 = admins2;
- }
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/User.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/User.java
index 2a5584294731..f7dd6afdc311 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/User.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/collections/list/User.java
@@ -4,20 +4,11 @@
*/
package org.hibernate.orm.test.boot.models.hbm.collections.list;
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-import jakarta.persistence.Basic;
-import jakarta.persistence.Table;
-
/**
* @author Steve Ebersole
*/
-@Entity
-@Table(name = "`users`")
public class User {
- @Id
private Integer id;
- @Basic
private String name;
protected User() {
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/entityname/DuplicateClassMappingTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/entityname/DuplicateClassMappingTests.java
deleted file mode 100644
index 8363a8a90633..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/entityname/DuplicateClassMappingTests.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.entityname;
-
-import org.hibernate.MappingException;
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.cfg.MappingSettings;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.fail;
-
-/**
- * @author Steve Ebersole
- */
-@SuppressWarnings("JUnitMalformedDeclaration")
-public class DuplicateClassMappingTests {
- @Test
- @DomainModel(xmlMappings = "mappings/models/hbm/entityname/hbm.xml")
- void testHbmXml(DomainModelScope domainModelScope) {
- assertThat( domainModelScope.getDomainModel().getEntityBinding( "BillingAddress" ) ).isNotNull();
- assertThat( domainModelScope.getDomainModel().getEntityBinding( "ShippingAddress" ) ).isNotNull();
- }
-
- @Test
- @ServiceRegistry( settings = @Setting( name= MappingSettings.TRANSFORM_HBM_XML, value = "true" ) )
- void testHbmXmlTransformation(ServiceRegistryScope registryScope) {
- final MetadataSources metadataSources = new MetadataSources( registryScope.getRegistry() );
- metadataSources.addResource( "mappings/models/hbm/entityname/hbm.xml" );
- try {
- metadataSources.buildMetadata();
- fail( "Expecting a failure" );
- }
- catch (MappingException expected) {
- assertThat( expected.getMessage() ).contains( Address.class.getName() );
- assertThat( expected.getMessage() ).contains( "ShippingAddress" );
- assertThat( expected.getMessage() ).contains( "BillingAddress" );
- }
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/intf/IPerson.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/intf/IPerson.java
deleted file mode 100644
index 97c86892d8fa..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/intf/IPerson.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.intf;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-
-/**
- * @author Steve Ebersole
- */
-@Entity
-public interface IPerson {
- @Id
- Integer getId();
- String getName();
- void setName(String name);
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/intf/InterfaceMappingTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/intf/InterfaceMappingTests.java
deleted file mode 100644
index f325dbc4b7dc..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/intf/InterfaceMappingTests.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.intf;
-
-import org.hibernate.MappingException;
-import org.hibernate.boot.Metadata;
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.boot.registry.StandardServiceRegistry;
-import org.hibernate.cfg.MappingSettings;
-
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.fail;
-
-/**
- * Tests for mapping interfaces as managed classes.
- *
- * @implNote This is something {@code hbm.xml} supported, and we want to make sure it fails in
- * a consistent manner.
- *
- * @author Steve Ebersole
- */
-@SuppressWarnings("JUnitMalformedDeclaration")
-public class InterfaceMappingTests {
- @ServiceRegistry
- @Test
- void testInterfaceAsEntity(ServiceRegistryScope registryScope) {
- try (StandardServiceRegistry serviceRegistry = registryScope.getRegistry()) {
- final Metadata metadata = new MetadataSources( serviceRegistry )
- .addAnnotatedClasses( IPerson.class, Person.class )
- .buildMetadata();
- }
- catch (MappingException expected) {
- assertThat( expected.getMessage() ).startsWith( "Only classes (not interfaces) may be mapped as @Entity :" );
- assertThat( expected.getMessage() ).endsWith( IPerson.class.getName() );
- }
- }
-
- @ServiceRegistry(settings = @Setting(name = MappingSettings.TRANSFORM_HBM_XML, value = "true"))
- @Test
- void testTransformedHbmXml(ServiceRegistryScope registryScope) {
- try (StandardServiceRegistry serviceRegistry = registryScope.getRegistry()) {
- final Metadata metadata = new MetadataSources( serviceRegistry )
- .addResource( "mappings/models/hbm/intf/mapped-interface.hbm.xml" )
- .buildMetadata();
- fail( "Expecting a failure" );
- }
- catch (MappingException expected) {
- }
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/intf/Person.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/intf/Person.java
deleted file mode 100644
index a4272dbcd328..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/intf/Person.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.intf;
-
-import jakarta.persistence.Entity;
-
-/**
- * @author Steve Ebersole
- */
-@Entity
-public class Person implements IPerson {
- private Integer id;
- private String name;
-
- public Person() {
- }
-
- public Person(Integer id, String name) {
- this.id = id;
- this.name = name;
- }
-
- @Override
- public Integer getId() {
- return id;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/inverse/Customer.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/inverse/Customer.java
deleted file mode 100644
index e6278979f009..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/inverse/Customer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.inverse;
-
-import java.util.Set;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-import jakarta.persistence.Basic;
-import jakarta.persistence.OneToMany;
-import jakarta.persistence.Table;
-
-/**
- * @author Steve Ebersole
- */
-@Entity
-@Table( name = "customers" )
-public class Customer {
- @Id
- private Integer id;
- @Basic
- private String name;
- @OneToMany( mappedBy = "customer" )
- private Set orders;
-
- protected Customer() {
- // for Hibernate use
- }
-
- public Customer(Integer id, String name) {
- this.id = id;
- this.name = name;
- }
-
- public Integer getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Set getOrders() {
- return orders;
- }
-
- public void setOrders(Set orders) {
- this.orders = orders;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/inverse/Order.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/inverse/Order.java
deleted file mode 100644
index 95bede72457c..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/inverse/Order.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.inverse;
-
-import java.time.Instant;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-import jakarta.persistence.Basic;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.Table;
-
-/**
- * @author Steve Ebersole
- */
-@Entity
-@Table( name = "orders" )
-public class Order {
- @Id
- private Integer id;
- @Basic
- private Instant timestamp;
- @ManyToOne
- @JoinColumn( name = "customer_fk" )
- private Customer customer;
-
- protected Order() {
- // for Hibernate use
- }
-
- public Order(Integer id, Instant timestamp) {
- this.id = id;
- this.timestamp = timestamp;
- }
-
- public Integer getId() {
- return id;
- }
-
- public Instant getTimestamp() {
- return timestamp;
- }
-
- public void setTimestamp(Instant timestamp) {
- this.timestamp = timestamp;
- }
-
- public Customer getCustomer() {
- return customer;
- }
-
- public void setCustomer(Customer customer) {
- this.customer = customer;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/inverse/SimpleInverseTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/inverse/SimpleInverseTests.java
deleted file mode 100644
index 610dffb1b273..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/inverse/SimpleInverseTests.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.inverse;
-
-import org.hibernate.cfg.MappingSettings;
-import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.KeyValue;
-import org.hibernate.mapping.OneToMany;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.ToOne;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * @author Steve Ebersole
- */
-@SuppressWarnings("JUnitMalformedDeclaration")
-public class SimpleInverseTests {
- @Test
- @DomainModel( annotatedClasses = {Customer.class, Order.class} )
- void testAnnotations(DomainModelScope modelScope) {
- verify( modelScope );
- }
-
- @Test
- @DomainModel(xmlMappings = "mappings/models/hbm/inverse/mapping.xml")
- void testMappingXml(DomainModelScope modelScope) {
- verify( modelScope );
- }
-
- @Test
- @ServiceRegistry( settings = @Setting( name = MappingSettings.TRANSFORM_HBM_XML, value = "true" ) )
- @DomainModel(xmlMappings = "mappings/models/hbm/inverse/hbm.xml")
- void testHbmXml(DomainModelScope modelScope) {
- verify( modelScope );
- }
-
- private void verify(DomainModelScope modelScope) {
- {
- final PersistentClass customerEntityBinding = modelScope.getEntityBinding( Customer.class );
- final Property ordersProperty = customerEntityBinding.getProperty( "orders" );
- final Collection ordersCollection = (Collection) ordersProperty.getValue();
- final KeyValue ordersCollectionKey = ordersCollection.getKey();
- assertThat( ordersCollectionKey.getColumns() ).hasSize( 1 );
- assertThat( ordersCollectionKey.getColumns().get( 0 ).getName() ).isEqualTo( "customer_fk" );
- final OneToMany childrenPropertyElement = (OneToMany) ordersCollection.getElement();
- assertThat( ordersCollection.isInverse() ).isTrue();
- assertThat( childrenPropertyElement.getColumns() ).hasSize( 1 );
- assertThat( childrenPropertyElement.getColumns().get( 0 ).getName() ).isEqualTo( "id" );
- }
-
- {
- final PersistentClass orderEntityBinding = modelScope.getEntityBinding( Order.class );
- final Property customerProperty = orderEntityBinding.getProperty( "customer" );
- final ToOne customerPropertyValue = (ToOne) customerProperty.getValue();
- assertThat( customerPropertyValue.isReferenceToPrimaryKey() ).isTrue();
- assertThat( customerPropertyValue.getColumns() ).hasSize( 1 );
- assertThat( customerPropertyValue.getColumns().get( 0 ).getName() ).isEqualTo( "customer_fk" );
- }
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/join/SecondaryTableTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/join/SecondaryTableTests.java
index 4407590d85c5..62f8907606f3 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/join/SecondaryTableTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/join/SecondaryTableTests.java
@@ -4,7 +4,6 @@
*/
package org.hibernate.orm.test.boot.models.hbm.join;
-import org.hibernate.cfg.MappingSettings;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.PersistentClass;
@@ -12,37 +11,24 @@
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
/**
+ * Tests parsing Hibernate extensions to {@code }
+ *
* @author Steve Ebersole
*/
@SuppressWarnings("JUnitMalformedDeclaration")
public class SecondaryTableTests {
@Test
- @DomainModel(xmlMappings = "mappings/models/hbm/join/hbm.xml")
- void baseline(DomainModelScope domainModelScope) {
- verifyModel( domainModelScope.getDomainModel().getEntityBinding( Person.class.getName() ) );
- }
-
- @Test
- @DomainModel(xmlMappings = "mappings/models/hbm/join/mapping.xml")
+ @DomainModel(xmlMappings = "mappings/models/join/mapping.xml")
void testMappingXml(DomainModelScope domainModelScope) {
verifyModel( domainModelScope.getDomainModel().getEntityBinding( Person.class.getName() ) );
}
- @Test
- @ServiceRegistry(settings = @Setting(name = MappingSettings.TRANSFORM_HBM_XML, value = "true"))
- @DomainModel(xmlMappings = "mappings/models/hbm/join/hbm.xml")
- void testJoinTransformations(DomainModelScope domainModelScope) {
- verifyModel( domainModelScope.getDomainModel().getEntityBinding( Person.class.getName() ) );
- }
-
private void verifyModel(PersistentClass entityBinding) {
assertThat( entityBinding.getJoins() ).hasSize( 2 );
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/joinformula/JoinColumnAndFormulaTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/joinformula/JoinColumnAndFormulaTests.java
index c77cb2efefbb..22027e54d69f 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/joinformula/JoinColumnAndFormulaTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/joinformula/JoinColumnAndFormulaTests.java
@@ -4,29 +4,26 @@
*/
package org.hibernate.orm.test.boot.models.hbm.joinformula;
-import org.hibernate.cfg.MappingSettings;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Formula;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Value;
-
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
/**
+ * Tests parsing a combination of {@code } and {@code }
* @author Steve Ebersole
*/
@SuppressWarnings("JUnitMalformedDeclaration")
public class JoinColumnAndFormulaTests {
@Test
- @DomainModel( xmlMappings = "mappings/models/hbm/joinformula/many-to-one-join-column-and-formula.xml" )
- void testHbmXml(DomainModelScope domainModelScope) {
+ @DomainModel( xmlMappings = "mappings/models/joinformula/many-to-one-join-column-and-formula.xml")
+ void testXml(DomainModelScope domainModelScope) {
verifyMapping( domainModelScope );
}
@@ -36,13 +33,6 @@ void testAnnotations(DomainModelScope domainModelScope) {
verifyMapping( domainModelScope );
}
- @Test
- @ServiceRegistry( settings = @Setting( name= MappingSettings.TRANSFORM_HBM_XML, value = "true" ) )
- @DomainModel( xmlMappings = "mappings/models/hbm/joinformula/many-to-one-join-column-and-formula.xml" )
- void testHbmXmlTransformed(DomainModelScope domainModelScope) {
- verifyMapping( domainModelScope );
- }
-
void verifyMapping(DomainModelScope domainModelScope) {
final PersistentClass entityBinding = domainModelScope.getEntityBinding( Contact.class );
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/joinformula/ManyToOneTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/joinformula/ManyToOneTests.java
index 842816159a37..bb5800ea5697 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/joinformula/ManyToOneTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/joinformula/ManyToOneTests.java
@@ -4,43 +4,26 @@
*/
package org.hibernate.orm.test.boot.models.hbm.joinformula;
-import org.hibernate.cfg.MappingSettings;
import org.hibernate.mapping.Formula;
import org.hibernate.mapping.ManyToOne;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.orm.test.unconstrained.Person;
-
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
+ * Tests parsing of {@code } for a many-to-one
+ *
* @author Steve Ebersole
*/
@SuppressWarnings("JUnitMalformedDeclaration")
public class ManyToOneTests {
@Test
- @DomainModel(xmlMappings = "org/hibernate/orm/test/unconstrained/Person.hbm.xml")
- void testHbmXml(DomainModelScope domainModelScope) {
- final PersistentClass personEntityBinding = domainModelScope.getDomainModel().getEntityBinding( Person.class.getName() );
- validate( personEntityBinding.getProperty( "employee" ) );
- }
-
- @Test
- @ServiceRegistry( settings = @Setting( name= MappingSettings.TRANSFORM_HBM_XML, value = "true" ) )
- @DomainModel(xmlMappings = "org/hibernate/orm/test/unconstrained/Person.hbm.xml")
- void testTransformation(DomainModelScope domainModelScope) {
- final PersistentClass personEntityBinding = domainModelScope.getDomainModel().getEntityBinding( Person.class.getName() );
- validate( personEntityBinding.getProperty( "employee" ) );
- }
-
- @Test
- @DomainModel(xmlMappings = "mappings/models/hbm/joinformula/many-to-one.xml")
+ @DomainModel(xmlMappings = "mappings/models/joinformula/many-to-one.xml")
void testMappingXml(DomainModelScope domainModelScope) {
final PersistentClass personEntityBinding = domainModelScope.getDomainModel().getEntityBinding( Person.class.getName() );
validate( personEntityBinding.getProperty( "employee" ) );
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/joinformula/OneToOneTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/joinformula/OneToOneTests.java
index bd54d6af01b5..a82bcee487f4 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/joinformula/OneToOneTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/joinformula/OneToOneTests.java
@@ -4,58 +4,26 @@
*/
package org.hibernate.orm.test.boot.models.hbm.joinformula;
-import org.hibernate.boot.Metadata;
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.boot.registry.StandardServiceRegistry;
-import org.hibernate.cfg.MappingSettings;
import org.hibernate.mapping.Formula;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.ToOne;
import org.hibernate.orm.test.onetoone.formula.Person;
-
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
+ * Tests parsing of {@code } for a one-to-one
+ *
* @author Steve Ebersole
*/
@SuppressWarnings("JUnitMalformedDeclaration")
public class OneToOneTests {
@Test
- @DomainModel(xmlMappings = "org/hibernate/orm/test/onetoone/formula/Person.hbm.xml")
- void testHbmXml(DomainModelScope domainModelScope) {
- final PersistentClass personEntityBinding = domainModelScope.getDomainModel().getEntityBinding( Person.class.getName() );
- validateAddress( personEntityBinding.getProperty( "address" ) );
- validateMailingAddress( personEntityBinding.getProperty( "mailingAddress" ) );
- }
-
- @Test
- @ServiceRegistry( settings = @Setting( name= MappingSettings.TRANSFORM_HBM_XML, value = "true" ) )
- void testTransformation(ServiceRegistryScope registryScope) {
- try {
- final StandardServiceRegistry serviceRegistry = registryScope.getRegistry();
- final MetadataSources metadataSources = new MetadataSources( serviceRegistry );
- metadataSources.addResource( "org/hibernate/orm/test/onetoone/formula/Person.hbm.xml" );
- final Metadata domainModel = metadataSources.buildMetadata();
-
- final PersistentClass personEntityBinding = domainModel.getEntityBinding( Person.class.getName() );
- validateAddress( personEntityBinding.getProperty( "address" ) );
- validateMailingAddress( personEntityBinding.getProperty( "mailingAddress" ) );
- }
- catch (UnsupportedOperationException e) {
- assertThat( e.getMessage() ).contains( "" );
- }
- }
-
- @Test
- @DomainModel(xmlMappings = "mappings/models/hbm/joinformula/one-to-one.xml")
+ @DomainModel(xmlMappings = "mappings/models/joinformula/one-to-one.xml")
void testMappingXml(DomainModelScope domainModelScope) {
final PersistentClass personEntityBinding = domainModelScope.getDomainModel().getEntityBinding( Person.class.getName() );
validateAddress( personEntityBinding.getProperty( "address" ) );
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/mappedsuper/Base.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/mappedsuper/Base.java
deleted file mode 100644
index 9c7aafe61b0b..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/mappedsuper/Base.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.mappedsuper;
-
-/**
- * @author Steve Ebersole
- */
-public class Base {
- private Integer id;
- private String name;
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/mappedsuper/ImpliedMappedSuperTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/mappedsuper/ImpliedMappedSuperTests.java
deleted file mode 100644
index aed141bf15cc..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/mappedsuper/ImpliedMappedSuperTests.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.mappedsuper;
-
-import org.hibernate.boot.Metadata;
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.cfg.MappingSettings;
-import org.hibernate.mapping.PersistentClass;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.FailureExpected;
-import org.hibernate.testing.orm.junit.Jira;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author Steve Ebersole
- */
-@SuppressWarnings("JUnitMalformedDeclaration")
-public class ImpliedMappedSuperTests {
- @Test
- @DomainModel( xmlMappings = "mappings/models/hbm/mappedsuper/implied-mapped-super.xml" )
- void testHbm(DomainModelScope domainModelScope) {
- verify( domainModelScope.getDomainModel() );
- }
-
- @Test
- @FailureExpected( reason = "Support for implied mapped-superclass from hbm.xml is not implemented yet" )
- @Jira( "https://hibernate.atlassian.net/browse/HHH-18387" )
- @ServiceRegistry( settings = @Setting( name = MappingSettings.TRANSFORM_HBM_XML, value = "true" ) )
- void testHbmTransformation(ServiceRegistryScope registryScope) {
- final Metadata domainModel = new MetadataSources( registryScope.getRegistry() )
- .addResource( "mappings/models/hbm/mappedsuper/implied-mapped-super.xml" )
- .buildMetadata();
- verify( domainModel );
- }
-
- private void verify(Metadata domainModel) {
- final PersistentClass thing1Binding = domainModel.getEntityBinding( Thing1.class.getName() );
- final PersistentClass thing2Binding = domainModel.getEntityBinding( Thing2.class.getName() );
-
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/mappedsuper/Thing1.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/mappedsuper/Thing1.java
deleted file mode 100644
index 2cc53c9ff07c..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/mappedsuper/Thing1.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.mappedsuper;
-
-/**
- * @author Steve Ebersole
- */
-public class Thing1 extends Base {
- private String stuff;
-
- public String getStuff() {
- return stuff;
- }
-
- public void setStuff(String stuff) {
- this.stuff = stuff;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/mappedsuper/Thing2.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/mappedsuper/Thing2.java
deleted file mode 100644
index e2b990666b67..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/mappedsuper/Thing2.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.mappedsuper;
-
-/**
- * @author Steve Ebersole
- */
-public class Thing2 extends Base {
- private String data;
-
- public String getData() {
- return data;
- }
-
- public void setData(String data) {
- this.data = data;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/notfound/HbmNotFoundTransformationTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/notfound/HbmNotFoundTransformationTests.java
index 5ca0b0229603..53e4171b2e6b 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/notfound/HbmNotFoundTransformationTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/notfound/HbmNotFoundTransformationTests.java
@@ -4,14 +4,11 @@
*/
package org.hibernate.orm.test.boot.models.hbm.notfound;
-import org.hibernate.cfg.MappingSettings;
import org.hibernate.orm.test.unconstrained.UnconstrainedTest;
import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
@@ -23,12 +20,11 @@
* @author Steve Ebersole
*/
@SuppressWarnings("JUnitMalformedDeclaration")
-@ServiceRegistry(settings = @Setting(name= MappingSettings.TRANSFORM_HBM_XML, value = "true"))
-@DomainModel(xmlMappings = "mappings/models/hbm/notfound/Person2.hbm.xml")
+@DomainModel(xmlMappings = "mappings/models/hbm/notfound/mapping.xml")
@SessionFactory
public class HbmNotFoundTransformationTests {
@Test
- void testNotFoundTransformation(SessionFactoryScope scope) {
+ void testNotFound(SessionFactoryScope scope) {
scope.inTransaction( (session) -> {
final Employee2 employee = new Employee2( 1, "employee" );
final Person2 person = new Person2( 1, "person", employee );
@@ -45,9 +41,6 @@ void testNotFoundTransformation(SessionFactoryScope scope) {
@AfterEach
void tearDown(SessionFactoryScope scope) {
- scope.inTransaction( (session) -> {
- session.createMutationQuery( "delete Person2" ).executeUpdate();
- session.createMutationQuery( "delete Employee2" ).executeUpdate();
- } );
+ scope.dropData();
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/properties/Address.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/properties/Address.java
deleted file mode 100644
index 52e45b0a83e3..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/properties/Address.java
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.properties;
-
-/**
- * @author Steve Ebersole
- */
-public class Address {
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/properties/PropertiesGroupingTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/properties/PropertiesGroupingTests.java
deleted file mode 100644
index e30a83908588..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/properties/PropertiesGroupingTests.java
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.properties;
-
-/**
- * Tests for {@code hbm.xml} {@code } grouping element
- *
- * @author Steve Ebersole
- */
-public class PropertiesGroupingTests {
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/properties/Server.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/properties/Server.java
deleted file mode 100644
index d892ff6dfc4f..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/properties/Server.java
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.properties;
-
-/**
- * @author Steve Ebersole
- */
-public class Server {
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/CompositeManyToOnePropertyRefTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/CompositeManyToOnePropertyRefTests.java
deleted file mode 100644
index 94060afcb69f..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/CompositeManyToOnePropertyRefTests.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.propertyref;
-
-import java.sql.Statement;
-
-import org.hibernate.annotations.PropertyRef;
-import org.hibernate.cfg.MappingSettings;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.ToOne;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Test;
-
-import jakarta.persistence.Column;
-import jakarta.persistence.Embeddable;
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.Table;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * @author Steve Ebersole
- */
-
-@SuppressWarnings("JUnitMalformedDeclaration")
-public class CompositeManyToOnePropertyRefTests {
- @Test
- @DomainModel(
- annotatedClasses = {Name.class, Person.class, Account.class},
- xmlMappings = "mappings/models/hbm/propertyref/composite-many-to-one.hbm.xml"
- )
- @SessionFactory
- void testHbm(DomainModelScope modelScope, SessionFactoryScope sfScope) {
- verify( modelScope.getEntityBinding( Account.class ), sfScope );
- }
-
- @Test
- @ServiceRegistry(settings = @Setting(name= MappingSettings.TRANSFORM_HBM_XML, value="true"))
- @DomainModel(
- annotatedClasses = {Name.class, Person.class, Account.class},
- xmlMappings = "mappings/models/hbm/propertyref/composite-many-to-one.hbm.xml"
- )
- @SessionFactory
- void testHbmTransformed(DomainModelScope modelScope, SessionFactoryScope sfScope) {
- verify( modelScope.getEntityBinding( Account.class ), sfScope );
- }
-
- @Test
- @DomainModel(annotatedClasses = {Name.class, Person.class, Account.class})
- @SessionFactory
- void testAnnotations(DomainModelScope modelScope, SessionFactoryScope sfScope) {
- verify( modelScope.getEntityBinding( Account.class ), sfScope );
- }
-
- private void verify(PersistentClass entityBinding, SessionFactoryScope sfScope) {
- final Property ownerProperty = entityBinding.getProperty( "owner" );
- final ToOne ownerPropertyValue = (ToOne) ownerProperty.getValue();
- assertThat( ownerPropertyValue.getReferencedPropertyName() ).isEqualTo( "name" );
-
- sfScope.inTransaction( (session) -> {
- final Person john = new Person( 1, "John", "Doe" );
- final Account account = new Account( 1, "savings", john );
- session.persist( john );
- session.persist( account );
- } );
- }
-
- @AfterEach
- @DomainModel(annotatedClasses = {Name.class, Person.class, Account.class})
- @SessionFactory
- void dropTestData(SessionFactoryScope scope) {
- scope.inTransaction( (session) -> {
- session.doWork( (connection) -> {
- try (Statement statement = connection.createStatement()) {
- final int deleteAccounts = statement.executeUpdate( "delete from accounts" );
- assertThat( deleteAccounts ).isEqualTo( 1 );
-
- final int deletePersons = statement.executeUpdate( "delete from persons" );
- assertThat( deletePersons ).isEqualTo( 1 );
- }
- } );
- } );
- }
-
- @Embeddable
- public static class Name {
- @Column(name = "fname")
- private String first;
- @Column(name = "lname")
- private String last;
-
- public Name() {
- }
-
- public Name(String first, String last) {
- this.first = first;
- this.last = last;
- }
-
- public void setFirst(String first) {
- this.first = first;
- }
-
- public void setLast(String last) {
- this.last = last;
- }
- }
-
- @Entity(name="Person")
- @Table(name="persons")
- public static class Person {
- @Id
- private Integer id;
- private Name name;
-
- public Person() {
- }
-
- public Person(Integer id, Name name) {
- this.id = id;
- this.name = name;
- }
-
- public Person(Integer id, String firstName, String lastName) {
- this.id = id;
- this.name = new Name( firstName, lastName );
- }
-
- public Integer getId() {
- return id;
- }
-
- public Name getName() {
- return name;
- }
-
- public void setName(Name name) {
- this.name = name;
- }
- }
-
- @Entity(name="Account")
- @Table(name="accounts")
- public static class Account {
- @Id
- private Integer id;
- private String name;
- @ManyToOne
- @PropertyRef("name")
- @JoinColumn(name="owner_name_first")
- @JoinColumn(name="owner_name_last")
- private Person owner;
-
- public Account() {
- }
-
- public Account(Integer id, String name, Person owner) {
- this.id = id;
- this.name = name;
- this.owner = owner;
- }
-
- public Integer getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Person getOwner() {
- return owner;
- }
-
- public void setOwner(Person owner) {
- this.owner = owner;
- }
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/GroupedPropertyRefTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/GroupedPropertyRefTests.java
deleted file mode 100644
index a09420207221..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/GroupedPropertyRefTests.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.propertyref;
-
-import java.util.List;
-
-import org.hibernate.boot.InvalidMappingException;
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.boot.registry.StandardServiceRegistry;
-import org.hibernate.cfg.MappingSettings;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.ToOne;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * Tests for {@code hbm.xml} {@code } grouping element
- *
- * @author Steve Ebersole
- */
-@SuppressWarnings("JUnitMalformedDeclaration")
-public class GroupedPropertyRefTests {
- @Test
- @DomainModel(annotatedClasses = {Person.class, Account.class}, xmlMappings = "mappings/models/hbm/propertyref/properties.hbm.xml" )
- @SessionFactory
- void testHbmXml(DomainModelScope domainModelScope, SessionFactoryScope sessionFactoryScope) {
- // baseline test for straight hbm.xml handling
- try {
- verify( domainModelScope, sessionFactoryScope );
- }
- finally {
- sessionFactoryScope.inTransaction( (session) -> {
- session.createMutationQuery( "delete GroupedPropertyRefTests$Account" ).executeUpdate();
- session.createMutationQuery( "delete GroupedPropertyRefTests$Person" ).executeUpdate();
- } );
- }
- }
-
- private void verify(DomainModelScope domainModelScope, SessionFactoryScope sessionFactoryScope) {
- final PersistentClass accountMapping = domainModelScope.getEntityBinding( Account.class );
-
- final Property ownerProperty = accountMapping.getProperty( "owner" );
- final ToOne ownerPropertyValue = (ToOne) ownerProperty.getValue();
- assertThat( ownerPropertyValue.getReferencedPropertyName() ).isEqualTo( "name" );
-
- sessionFactoryScope.inTransaction( (session) -> {
- final Person john = new Person( 1, "John", "Doe" );
- final Account account = new Account( 1, "savings", john );
- session.persist( john );
- session.persist( account );
- } );
-
- sessionFactoryScope.inTransaction( (session) -> {
- final List accounts = session.createSelectionQuery(
- "from GroupedPropertyRefTests$Account a join fetch a.owner",
- Account.class ).list();
- assertThat( accounts ).hasSize( 1 );
- } );
- }
-
- @Test
- @ServiceRegistry(settings = @Setting(name= MappingSettings.TRANSFORM_HBM_XML, value="true"))
- void testTransformed(ServiceRegistryScope registryScope) {
- // test the transformation - should be an error as this is unsupported
- try {
- final StandardServiceRegistry serviceRegistry = registryScope.getRegistry();
- final MetadataSources metadataSources = new MetadataSources( serviceRegistry );
- metadataSources.addResource( "mappings/models/hbm/propertyref/properties.hbm.xml" );
- }
- catch (InvalidMappingException expected) {
- assertThat( expected.getCause() ).isInstanceOf( UnsupportedOperationException.class );
- assertThat( expected.getCause().getMessage() ).startsWith( "" );
- }
- }
-
- public static class Person {
- private Integer id;
- private String firstName;
- private String lastName;
-
- public Person() {
- }
-
- public Person(Integer id, String firstName, String lastName) {
- this.id = id;
- this.firstName = firstName;
- this.lastName = lastName;
- }
-
- public Integer getId() {
- return id;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
- }
-
- public static class Account {
- private Integer id;
- private String name;
- private Person owner;
-
- public Account() {
- }
-
- public Account(Integer id, String name, Person owner) {
- this.id = id;
- this.name = name;
- this.owner = owner;
- }
-
- public Integer getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Person getOwner() {
- return owner;
- }
-
- public void setOwner(Person owner) {
- this.owner = owner;
- }
- }
-
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/ManyToOnePropertyRefTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/ManyToOnePropertyRefTests.java
deleted file mode 100644
index 4a1b2ea8723c..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/ManyToOnePropertyRefTests.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.propertyref;
-
-import java.sql.Statement;
-
-import org.hibernate.annotations.PropertyRef;
-import org.hibernate.cfg.MappingSettings;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.ToOne;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.Table;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * @author Steve Ebersole
- */
-@SuppressWarnings("JUnitMalformedDeclaration")
-public class ManyToOnePropertyRefTests {
- @Test
- @DomainModel(
- annotatedClasses = {Employee.class, TaxInformation.class},
- xmlMappings = "mappings/models/hbm/propertyref/many-to-one.hbm.xml"
- )
- @SessionFactory
- void testBasicPropertyRefHbm(DomainModelScope modelScope, SessionFactoryScope sfScope) {
- verify( modelScope.getEntityBinding( TaxInformation.class ), sfScope );
- }
-
- private void verify(PersistentClass entityBinding, SessionFactoryScope sfScope) {
- final Property employeeProp = entityBinding.getProperty( "employee" );
- final ToOne employeePropValue = (ToOne) employeeProp.getValue();
- assertThat( employeePropValue.getReferencedPropertyName() ).isEqualTo( "socialSecurityNumber" );
-
- try {
- sfScope.inTransaction( (session) -> {
- final Employee john = new Employee( 1, "John", "123-45-6789" );
- final TaxInformation taxInformation = new TaxInformation( 1, john, 123.45 );
- session.persist( john );
- session.persist( taxInformation );
- } );
- }
- finally {
- dropTestData( sfScope );
- }
- }
-
- void dropTestData(SessionFactoryScope scope) {
- scope.inTransaction( (session) -> {
- session.doWork( (connection) -> {
- try (Statement statement = connection.createStatement()) {
- final int deleteFromTaxInfo = statement.executeUpdate( "delete from tax_info" );
- assertThat( deleteFromTaxInfo ).isEqualTo( 1 );
-
- final int deleteFromEmployee = statement.executeUpdate( "delete from employee" );
- assertThat( deleteFromEmployee ).isEqualTo( 1 );
- }
- } );
- } );
- }
-
- @Test
- @ServiceRegistry(settings = @Setting(name=MappingSettings.TRANSFORM_HBM_XML, value="true"))
- @DomainModel(
- annotatedClasses = {Employee.class, TaxInformation.class},
- xmlMappings = "mappings/models/hbm/propertyref/many-to-one.hbm.xml"
- )
- @SessionFactory
- void testBasicPropertyRefHbmTransformed(DomainModelScope modelScope, SessionFactoryScope sfScope) {
- verify( modelScope.getEntityBinding( TaxInformation.class ), sfScope );
- }
-
- @Test
- @DomainModel(annotatedClasses = {Employee.class, TaxInformation.class})
- @SessionFactory
- void testBasicPropertyRef(DomainModelScope modelScope, SessionFactoryScope sfScope) {
- verify( modelScope.getEntityBinding( TaxInformation.class ), sfScope );
- }
-
- /**
- * @author Steve Ebersole
- */
- @Entity(name = "Employee")
- @Table(name = "employee")
- public static class Employee {
- @Id
- private Integer id;
- private String name;
- private String socialSecurityNumber;
-
- public Employee() {
- }
-
- public Employee(Integer id, String name, String socialSecurityNumber) {
- this.id = id;
- this.name = name;
- this.socialSecurityNumber = socialSecurityNumber;
- }
- }
-
- /**
- * @author Steve Ebersole
- */
- @Entity(name = "TaxInformation")
- @Table(name = "tax_info")
- public static class TaxInformation {
- @Id
- private Integer id;
- @ManyToOne
- @PropertyRef("socialSecurityNumber")
- private Employee employee;
- private double withholding;
-
- public TaxInformation() {
- }
-
- public TaxInformation(Integer id, Employee employee, double withholding) {
- this.id = id;
- this.employee = employee;
- this.withholding = withholding;
- }
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/ReferenceManyToOneTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/ReferenceManyToOneTests.java
deleted file mode 100644
index 2b424029f6ef..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/ReferenceManyToOneTests.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.propertyref;
-
-import java.io.StringWriter;
-
-import org.hibernate.annotations.PropertyRef;
-import org.hibernate.cfg.MappingSettings;
-import org.hibernate.internal.util.StringHelper;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.FailureExpected;
-import org.hibernate.testing.orm.junit.Jira;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.hibernate.testing.schema.SchemaCreateHelper;
-import org.junit.jupiter.api.Test;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToOne;
-import jakarta.persistence.Table;
-
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-
-/**
- * @author Steve Ebersole
- */
-@SuppressWarnings("JUnitMalformedDeclaration")
-@Jira( "https://hibernate.atlassian.net/browse/HHH-18396" )
-public class ReferenceManyToOneTests {
- @Test
- @ServiceRegistry( settings = @Setting( name = MappingSettings.TRANSFORM_HBM_XML, value = "false" ) )
- @DomainModel(xmlMappings = "mappings/models/hbm/propertyref/ref-one-to-one.hbm.xml")
- void testHbm(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
- verifySchema( registryScope, domainModelScope );
- }
-
- @Test
- @FailureExpected( reason = "Support for property-ref pointing to a to-one not yet implemented in annotations nor mapping.xml", jiraKey = "HHH-18396" )
- @ServiceRegistry( settings = @Setting( name = MappingSettings.TRANSFORM_HBM_XML, value = "true" ) )
- @DomainModel(xmlMappings = "mappings/models/hbm/propertyref/ref-one-to-one.hbm.xml")
- void testHbmTransformed(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
- verifySchema( registryScope, domainModelScope );
- }
-
- @Test
- @FailureExpected( reason = "Support for property-ref pointing to a to-one not yet implemented in annotations nor mapping.xml", jiraKey = "HHH-18396" )
- @ServiceRegistry( settings = @Setting( name = MappingSettings.TRANSFORM_HBM_XML, value = "false" ) )
- @DomainModel( annotatedClasses = {Thing.class, Info.class} )
- void testAnnotations(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
- verifySchema( registryScope, domainModelScope );
- }
-
- private void verifySchema(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
- final String schemaScript = toSchemaScript( registryScope, domainModelScope );
- assertThat( schemaScript ).doesNotContainIgnoringCase( "owner_id", "info_id" );
- assertThat( StringHelper.count( schemaScript, "foreign key (" ) ).isEqualTo( 1 );
- }
-
- private String toSchemaScript(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
- final StringWriter stringWriter = new StringWriter();
- SchemaCreateHelper.createOnlyToWriter( domainModelScope.getDomainModel(), registryScope.getRegistry(), stringWriter );
-
- System.out.println( "Schema" );
- System.out.println( "------" );
- System.out.println( stringWriter );
-
- return stringWriter.toString();
- }
-
- @Entity(name="Thing")
- @Table(name="things")
- @SuppressWarnings("unused")
- public static class Thing {
- @Id
- private Integer id;
- private String name;
- @OneToOne
- @PropertyRef( "owner" )
- private Info info;
- }
-
- @Entity(name="Info")
- @Table(name="infos")
- @SuppressWarnings("unused")
- public static class Info {
- @Id
- private Integer id;
- private String name;
- @ManyToOne
- private Thing owner;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/ReferenceOneToOneTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/ReferenceOneToOneTests.java
deleted file mode 100644
index 894802ed7e8f..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/propertyref/ReferenceOneToOneTests.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.boot.models.hbm.propertyref;
-
-import java.io.StringWriter;
-
-import org.hibernate.annotations.PropertyRef;
-import org.hibernate.cfg.MappingSettings;
-import org.hibernate.dialect.H2Dialect;
-import org.hibernate.internal.util.StringHelper;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.DomainModelScope;
-import org.hibernate.testing.orm.junit.FailureExpected;
-import org.hibernate.testing.orm.junit.Jira;
-import org.hibernate.testing.orm.junit.RequiresDialect;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.hibernate.testing.schema.SchemaCreateHelper;
-import org.junit.jupiter.api.Test;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-import jakarta.persistence.OneToOne;
-import jakarta.persistence.Table;
-
-import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
-
-/**
- * @implNote Limited to H2 as the dialect is irrelevant and allows us to assert specific, expected syntax
- *
- * @author Steve Ebersole
- */
-@SuppressWarnings("JUnitMalformedDeclaration")
-@Jira( "https://hibernate.atlassian.net/browse/HHH-18396" )
-@RequiresDialect( H2Dialect.class )
-public class ReferenceOneToOneTests {
- @Test
- @ServiceRegistry( settings = @Setting( name = MappingSettings.TRANSFORM_HBM_XML, value = "false" ) )
- @DomainModel(xmlMappings = "mappings/models/hbm/propertyref/ref-one-to-one.hbm.xml")
- void testHbm(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
- verifySchema( registryScope, domainModelScope );
- }
-
- @Test
- @FailureExpected( reason = "Support for property-ref pointing to a to-one not yet implemented in annotations nor mapping.xml", jiraKey = "HHH-18396" )
- @ServiceRegistry( settings = @Setting( name = MappingSettings.TRANSFORM_HBM_XML, value = "true" ) )
- @DomainModel(xmlMappings = "mappings/models/hbm/propertyref/ref-one-to-one.hbm.xml")
- void testHbmTransformed(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
- verifySchema( registryScope, domainModelScope );
- }
-
- @Test
- @FailureExpected( reason = "Support for property-ref pointing to a to-one not yet implemented in annotations nor mapping.xml", jiraKey = "HHH-18396" )
- @ServiceRegistry( settings = @Setting( name = MappingSettings.TRANSFORM_HBM_XML, value = "false" ) )
- @DomainModel( annotatedClasses = {Thing.class, Info.class} )
- void testAnnotations(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
- verifySchema( registryScope, domainModelScope );
- }
-
- private void verifySchema(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
- final String schemaScript = toSchemaScript( registryScope, domainModelScope );
- assertThat( schemaScript ).doesNotContainIgnoringCase( "owner_id", "info_id" );
- assertThat( StringHelper.count( schemaScript, "foreign key (" ) ).isEqualTo( 1 );
- }
-
- private String toSchemaScript(ServiceRegistryScope registryScope, DomainModelScope domainModelScope) {
- final StringWriter stringWriter = new StringWriter();
- SchemaCreateHelper.createOnlyToWriter( domainModelScope.getDomainModel(), registryScope.getRegistry(), stringWriter );
-
- System.out.println( "Schema" );
- System.out.println( "------" );
- System.out.println( stringWriter );
-
- return stringWriter.toString();
- }
-
- @Entity(name="Thing")
- @Table(name="things")
- @SuppressWarnings("unused")
- public static class Thing {
- @Id
- private Integer id;
- private String name;
- @OneToOne
- @PropertyRef( "owner" )
- private Info info;
- }
-
- @Entity(name="Info")
- @Table(name="infos")
- @SuppressWarnings("unused")
- public static class Info {
- @Id
- private Integer id;
- private String name;
- @OneToOne
- private Thing owner;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/type/SpecialTypeTransformationTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/type/ReflectiveTypeTests.java
similarity index 76%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/type/SpecialTypeTransformationTests.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/type/ReflectiveTypeTests.java
index 46972f5f02aa..ad243a037c49 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/type/SpecialTypeTransformationTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/type/ReflectiveTypeTests.java
@@ -43,41 +43,21 @@
*/
@SuppressWarnings("JUnitMalformedDeclaration")
@RequiresDialect( H2Dialect.class )
-public class SpecialTypeTransformationTests {
+public class ReflectiveTypeTests {
@Test
@ServiceRegistry(settings = {
@Setting(name = MappingSettings.JAVA_TIME_USE_DIRECT_JDBC, value = "true"),
- // SqlTypes.INSTANT
- @Setting(name = MappingSettings.PREFERRED_INSTANT_JDBC_TYPE, value = "3008")
+ @Setting(name = MappingSettings.PREFERRED_INSTANT_JDBC_TYPE, value = "INSTANT")
} )
@DomainModel(xmlMappings = "mappings/models/hbm/type/basics.xml")
- void testBasicsHbmXml(DomainModelScope scope) {
- scope.withHierarchy( EntityOfBasics.class, this::verify );
- }
-
- @Test
- @ServiceRegistry(settings = {
- @Setting(name = MappingSettings.JAVA_TIME_USE_DIRECT_JDBC, value = "true"),
- // SqlTypes.INSTANT
- @Setting(name = MappingSettings.PREFERRED_INSTANT_JDBC_TYPE, value = "3008"),
- @Setting(name = MappingSettings.TRANSFORM_HBM_XML, value = "true")
- } )
- @DomainModel(xmlMappings = "mappings/models/hbm/type/basics.xml")
- void testBasicsTransformed(DomainModelScope scope) {
+ void testBasicsXml(DomainModelScope scope) {
scope.withHierarchy( EntityOfBasics.class, this::verify );
}
@Test
@ServiceRegistry
@DomainModel(xmlMappings = "mappings/models/hbm/type/element-collections.xml")
- void testElementCollectionsHbmXml(DomainModelScope scope) {
- scope.withHierarchy( EntityWithElementCollections.class, this::verifyElementCollections );
- }
-
- @Test
- @ServiceRegistry(settings = @Setting(name = MappingSettings.TRANSFORM_HBM_XML, value = "true"))
- @DomainModel(xmlMappings = "mappings/models/hbm/type/element-collections.xml")
- void testElementCollectionsTransformed(DomainModelScope scope) {
+ void testElementCollectionsXml(DomainModelScope scope) {
scope.withHierarchy( EntityWithElementCollections.class, this::verifyElementCollections );
}
@@ -97,7 +77,7 @@ private void verify(RootClass rootClass) {
verify( rootClass, "theTimestamp", JdbcTimestampJavaType.class, SqlTypes.TIMESTAMP );
}
- private void verify(RootClass rootClass, String attributeName, Class extends BasicJavaType>> expectedJavaType, int expectedJdbcTypeCode) {
+ private static void verify(RootClass rootClass, String attributeName, Class extends BasicJavaType>> expectedJavaType, int expectedJdbcTypeCode) {
final Property attribute = rootClass.getProperty( attributeName );
assertThat( attribute.getType() ).isInstanceOf( BasicType.class );
verify( (BasicType>) attribute.getType(), expectedJavaType, expectedJdbcTypeCode );
@@ -111,13 +91,13 @@ private void verifyElementCollections(RootClass rootClass) {
verifyElementCollection( rootClass, "listOfUuids", UUIDJavaType.class, SqlTypes.OTHER );
}
- private void verifyElementCollection(RootClass rootClass, String name, Class extends BasicJavaType>> expectedJavaType, int expectedJdbcTypeCode) {
+ private static void verifyElementCollection(RootClass rootClass, String name, Class extends BasicJavaType>> expectedJavaType, int expectedJdbcTypeCode) {
final Property property = rootClass.getProperty( name );
final Collection propertyValue = (Collection) property.getValue();
verify( (BasicType>) propertyValue.getElement().getType(), expectedJavaType, expectedJdbcTypeCode );
}
- private void verify(BasicType> type, Class extends BasicJavaType>> expectedJavaType, int expectedJdbcTypeCode) {
+ private static void verify(BasicType> type, Class extends BasicJavaType>> expectedJavaType, int expectedJdbcTypeCode) {
assertThat( type.getJavaTypeDescriptor().getClass() ).isEqualTo( expectedJavaType );
assertThat( type.getJdbcType().getJdbcTypeCode() ).isEqualTo( expectedJdbcTypeCode );
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/XmlProcessingSmokeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/XmlProcessingSmokeTests.java
index f70ebbcb0c4f..3c2b88a65e50 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/XmlProcessingSmokeTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/XmlProcessingSmokeTests.java
@@ -176,7 +176,7 @@ private void validateFilterDefs(Map filterDefRegi
assertThat( amountFilter.getDefaultCondition() ).isEqualTo( "amount = :amount" );
assertThat( amountFilter.getParameterTypes() ).hasSize( 1 );
final ClassDetails amountParameterType = amountFilter.getParameterTypes().get( "amount" );
- assertThat( amountParameterType.getClassName() ).isEqualTo( Integer.class.getName() );
+ assertThat( amountParameterType.getClassName() ).isEqualTo( int.class.getName() );
final FilterDefRegistration nameFilter = filterDefRegistrations.get( "name_filter" );
assertThat( nameFilter.getDefaultCondition() ).isEqualTo( "name = :name" );
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/column/transform/ModelTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/column/transform/ModelTests.java
index 7a8186461c2f..64a988a75536 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/column/transform/ModelTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/column/transform/ModelTests.java
@@ -8,8 +8,6 @@
import org.hibernate.boot.model.process.spi.ManagedResources;
import org.hibernate.boot.model.source.internal.annotations.AdditionalManagedResourcesImpl;
import org.hibernate.boot.registry.StandardServiceRegistry;
-import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.cfg.MappingSettings;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Property;
import org.hibernate.models.spi.ClassDetails;
@@ -20,7 +18,6 @@
import org.hibernate.testing.orm.junit.DomainModelScope;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
@@ -48,28 +45,6 @@ void testMappingXml(ServiceRegistryScope scope) {
assertThat( transformerAnn.write() ).isEqualTo( "? * 100.00" );
}
- @ServiceRegistry(settings = {
- @Setting(name = MappingSettings.TRANSFORM_HBM_XML, value = "true"),
- @Setting( name = AvailableSettings.VALIDATE_XML, value = "true")
- })
- @Test
- void testHbmXml(ServiceRegistryScope scope) {
- final String hbmXmlResourceName = "mappings/models/column/transform/hbm.xml";
-
- final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder( scope.getRegistry() )
- .addXmlMappings( hbmXmlResourceName )
- .build();
- final StandardServiceRegistry serviceRegistry = scope.getRegistry();
- final ModelsContext ModelsContext = createBuildingContext( managedResources, serviceRegistry );
-
- final ClassDetails classDetails = ModelsContext.getClassDetailsRegistry().getClassDetails( Item.class.getName() );
- final FieldDetails costField = classDetails.findFieldByName( "cost" );
- final ColumnTransformer transformerAnn = costField.getAnnotationUsage( ColumnTransformer.class, ModelsContext );
- assertThat( transformerAnn ).isNotNull();
- assertThat( transformerAnn.read() ).isEqualTo( "cost / 100.00" );
- assertThat( transformerAnn.write() ).isEqualTo( "? * 100.00" );
- }
-
@ServiceRegistry
@DomainModel(xmlMappings = "mappings/models/column/transform/mapping.xml")
@Test
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/dynamic/DynamicModelTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/dynamic/DynamicModelTests.java
index 6d64dc6b998e..1bdc8fe6ccaa 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/dynamic/DynamicModelTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/dynamic/DynamicModelTests.java
@@ -23,6 +23,9 @@
import org.hibernate.models.spi.FieldDetails;
import org.hibernate.models.spi.ModelsContext;
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.DomainModelScope;
+import org.hibernate.testing.orm.junit.NotImplementedYet;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.ServiceRegistryScope;
import org.junit.jupiter.api.Test;
@@ -45,6 +48,12 @@
*/
@SuppressWarnings("JUnitMalformedDeclaration")
public class DynamicModelTests {
+ @Test
+ @DomainModel(xmlMappings = "mappings/models/dynamic/dynamic-simple.xml")
+ void testSimpleDynamicModel2(DomainModelScope modelScope) {
+ assertThat( modelScope.getDomainModel().getEntityBinding( "SimpleEntity" ) ).isNotNull();
+ }
+
@Test
@ServiceRegistry
void testSimpleDynamicModel(ServiceRegistryScope registryScope) {
@@ -72,6 +81,7 @@ void testSimpleDynamicModel(ServiceRegistryScope registryScope) {
@Test
@ServiceRegistry
+ @NotImplementedYet( reason = "Support for dynamic embeddables is not fully baked" )
void testSemiSimpleDynamicModel(ServiceRegistryScope registryScope) {
final ManagedResources managedResources = new AdditionalManagedResourcesImpl.Builder()
.addXmlMappings( "mappings/models/dynamic/dynamic-semi-simple.xml" )
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/dynamic/DynamicTypingTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/dynamic/DynamicTypingTests.java
new file mode 100644
index 000000000000..396dfd532916
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/xml/dynamic/DynamicTypingTests.java
@@ -0,0 +1,91 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.boot.models.xml.dynamic;
+
+import org.hibernate.boot.spi.MetadataImplementor;
+import org.hibernate.cfg.MappingSettings;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.RootClass;
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.DomainModelScope;
+import org.hibernate.testing.orm.junit.ServiceRegistry;
+import org.hibernate.testing.orm.junit.Setting;
+import org.hibernate.type.BasicType;
+import org.hibernate.type.SqlTypes;
+import org.hibernate.type.descriptor.java.BasicJavaType;
+import org.hibernate.type.descriptor.java.BooleanJavaType;
+import org.hibernate.type.descriptor.java.ClobJavaType;
+import org.hibernate.type.descriptor.java.InstantJavaType;
+import org.hibernate.type.descriptor.java.IntegerJavaType;
+import org.hibernate.type.descriptor.java.JdbcDateJavaType;
+import org.hibernate.type.descriptor.java.JdbcTimeJavaType;
+import org.hibernate.type.descriptor.java.JdbcTimestampJavaType;
+import org.hibernate.type.descriptor.java.StringJavaType;
+import org.hibernate.type.descriptor.java.UUIDJavaType;
+import org.hibernate.type.descriptor.java.UrlJavaType;
+import org.hibernate.type.descriptor.jdbc.JdbcType;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author Steve Ebersole
+ */
+@SuppressWarnings("JUnitMalformedDeclaration")
+public class DynamicTypingTests {
+ @ServiceRegistry(settings = {
+ @Setting(name = MappingSettings.JAVA_TIME_USE_DIRECT_JDBC, value = "true"),
+ @Setting(name = MappingSettings.PREFERRED_INSTANT_JDBC_TYPE, value = "INSTANT")
+ } )
+ @DomainModel(xmlMappings = "mappings/models/dynamic/dynamic-typing.xml")
+ @Test
+ void testDynamicModelBasicTyping(DomainModelScope modelScope) {
+ final MetadataImplementor domainModel = modelScope.getDomainModel();
+ final JdbcType uuidJdbcType = domainModel
+ .getTypeConfiguration()
+ .getJdbcTypeRegistry()
+ .getDescriptor( SqlTypes.UUID );
+ final JdbcType booleanJdbcType = domainModel
+ .getTypeConfiguration()
+ .getJdbcTypeRegistry()
+ .getDescriptor( SqlTypes.BOOLEAN );
+
+ final RootClass entityBinding = (RootClass) domainModel.getEntityBinding( "TheEntity" );
+ assertThat( entityBinding ).isNotNull();
+
+ verifyBasicAttribute( entityBinding, "theBoolean", BooleanJavaType.class, booleanJdbcType.getJdbcTypeCode() );
+ verifyBasicAttribute( entityBinding, "theString", StringJavaType.class, SqlTypes.VARCHAR );
+ verifyBasicAttribute( entityBinding, "theInt", IntegerJavaType.class, SqlTypes.INTEGER );
+ verifyBasicAttribute( entityBinding, "theInteger", IntegerJavaType.class, SqlTypes.INTEGER );
+ verifyBasicAttribute( entityBinding, "theUrl", UrlJavaType.class, SqlTypes.VARCHAR );
+ verifyBasicAttribute( entityBinding, "theClob", ClobJavaType.class, SqlTypes.CLOB );
+ verifyBasicAttribute( entityBinding, "theInstant", InstantJavaType.class, SqlTypes.INSTANT );
+ verifyBasicAttribute( entityBinding, "theDate", JdbcDateJavaType.class, SqlTypes.DATE );
+ verifyBasicAttribute( entityBinding, "theTime", JdbcTimeJavaType.class, SqlTypes.TIME );
+ verifyBasicAttribute( entityBinding, "theTimestamp", JdbcTimestampJavaType.class, SqlTypes.TIMESTAMP );
+
+ verifyElementCollection( entityBinding, "listOfIntegers", IntegerJavaType.class, SqlTypes.INTEGER );
+ verifyElementCollection( entityBinding, "listOfUuids", UUIDJavaType.class, uuidJdbcType.getJdbcTypeCode() );
+ }
+
+
+ private static void verifyBasicAttribute(RootClass rootClass, String attributeName, Class extends BasicJavaType>> expectedJavaType, int expectedJdbcTypeCode) {
+ final Property attribute = rootClass.getProperty( attributeName );
+ assertThat( attribute.getType() ).isInstanceOf( BasicType.class );
+ verifyBasicMapping( (BasicType>) attribute.getType(), expectedJavaType, expectedJdbcTypeCode );
+ }
+
+ private static void verifyBasicMapping(BasicType> type, Class extends BasicJavaType>> expectedJavaType, int expectedJdbcTypeCode) {
+ assertThat( type.getJavaTypeDescriptor().getClass() ).isEqualTo( expectedJavaType );
+ assertThat( type.getJdbcType().getJdbcTypeCode() ).isEqualTo( expectedJdbcTypeCode );
+ }
+
+ private static void verifyElementCollection(RootClass rootClass, String name, Class extends BasicJavaType>> expectedJavaType, int expectedJdbcTypeCode) {
+ final Property property = rootClass.getProperty( name );
+ final Collection propertyValue = (Collection) property.getValue();
+ verifyBasicMapping( (BasicType>) propertyValue.getElement().getType(), expectedJavaType, expectedJdbcTypeCode );
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cacheable/CacheableHbmXmlTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cacheable/CacheableHbmXmlTest.java
deleted file mode 100644
index 71e6e130d5a2..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cacheable/CacheableHbmXmlTest.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.bootstrap.binding.hbm.cacheable;
-
-import java.io.File;
-import java.net.URL;
-
-import org.hibernate.boot.MappingException;
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.boot.jaxb.internal.CacheableFileXmlSource;
-import org.hibernate.boot.jaxb.internal.MappingBinder;
-import org.hibernate.boot.registry.StandardServiceRegistry;
-import org.hibernate.boot.spi.XmlMappingBinderAccess;
-
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.io.TempDir;
-
-import static org.junit.jupiter.api.Assertions.fail;
-
-/**
- * Originally developed to help diagnose HHH-10131 - the original tests
- * check 4 conditions:
- * - strict usage where the cached file does exist
- * - strict usage where the cached file does not exist
- * - non-strict usage where the cached file does exist
- * - non-strict usage where the cached file does not exist
- *
- *
- * @author Steve Ebersole
- */
-@ServiceRegistry()
-public class CacheableHbmXmlTest {
-
- private static final String HBM_RESOURCE_NAME = "org/hibernate/orm/test/bootstrap/binding/hbm/cacheable/SimpleEntity.hbm.xml";
-
- private static MappingBinder binder;
- private static File hbmXmlFile;
-
- @BeforeAll
- public static void prepareFixtures(ServiceRegistryScope scope) throws Exception {
- binder = new XmlMappingBinderAccess( scope.getRegistry() ).getMappingBinder();
-
- final URL hbmXmlUrl = CacheableHbmXmlTest.class.getClassLoader().getResource( HBM_RESOURCE_NAME );
- if ( hbmXmlUrl == null ) {
- throw couldNotFindHbmXmlResource();
- }
- hbmXmlFile = new File( hbmXmlUrl.getFile() );
- if ( ! hbmXmlFile.exists() ) {
- throw couldNotFindHbmXmlFile( hbmXmlFile );
- }
- }
-
- private static Exception couldNotFindHbmXmlResource() {
- throw new IllegalStateException( "Could not locate `" + HBM_RESOURCE_NAME + "` by resource lookup" );
- }
-
- private static Exception couldNotFindHbmXmlFile(File file) {
- throw new IllegalStateException(
- "File `" + file.getAbsolutePath() + "` resolved from `" + HBM_RESOURCE_NAME + "` resource-lookup does not exist"
- );
- }
-
- @Test
- public void testStrictlyWithExistingFile(ServiceRegistryScope serviceRegistryScope, @TempDir File binOutputDir) {
- final StandardServiceRegistry ssr = serviceRegistryScope.getRegistry();
-
- // create the cacheable file so that it exists before we try to build the boot model
- createBinFile( binOutputDir );
-
- try {
- new MetadataSources( ssr ).addCacheableFileStrictly( hbmXmlFile, binOutputDir ).buildMetadata();
- }
- catch (MappingException e) {
- fail( "addCacheableFileStrictly led to MappingException when bin file existed" );
- }
- }
-
- @Test
- public void testStrictlyWithNoExistingFile(ServiceRegistryScope serviceRegistryScope, @TempDir File binOutputDir) {
- try {
- final StandardServiceRegistry ssr = serviceRegistryScope.getRegistry();
- new MetadataSources( ssr )
- .addCacheableFileStrictly( hbmXmlFile, binOutputDir )
- .buildMetadata();
- fail( "addCacheableFileStrictly should be led to MappingException when bin file does not exist" );
- }
- catch (MappingException ignore) {
- // this is the expected result
- }
- }
-
- @Test
- public void testNonStrictlyWithExistingFile(ServiceRegistryScope serviceRegistryScope, @TempDir File binOutputDir) {
- final StandardServiceRegistry ssr = serviceRegistryScope.getRegistry();
-
- // create the cacheable file so that it exists before we try to build the boot model
- createBinFile( binOutputDir );
-
- try {
- new MetadataSources( ssr ).addCacheableFile( hbmXmlFile, binOutputDir ).buildMetadata();
- }
- catch (MappingException e) {
- fail( "addCacheableFileStrictly led to MappingException when bin file existed" );
- }
- }
-
- @Test
- public void testNonStrictlyWithNoExistingFile(ServiceRegistryScope serviceRegistryScope, @TempDir File binOutputDir) {
- final StandardServiceRegistry ssr = serviceRegistryScope.getRegistry();
- new MetadataSources( ssr ).addCacheableFile( hbmXmlFile, binOutputDir ).buildMetadata();
- }
-
- private void createBinFile(File binOutputDir) {
- final String outputName = hbmXmlFile.getName() + ".bin";
- final File file = new File( binOutputDir, outputName );
- CacheableFileXmlSource.createSerFile( hbmXmlFile, file, binder );
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicBindingTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicBindingTests.java
deleted file mode 100644
index efb0e381e66d..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicBindingTests.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.bootstrap.binding.hbm.cid.nonaggregated.dynamic;
-
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.metamodel.mapping.AttributeMapping;
-import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
-import org.hibernate.metamodel.mapping.internal.EmbeddedIdentifierMappingImpl;
-import org.hibernate.persister.entity.EntityPersister;
-
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * @author Steve Ebersole
- */
-@ServiceRegistry(
- settings = @Setting( name = AvailableSettings.HBM2DDL_AUTO, value = "create-drop" )
-)
-public class DynamicCompositeIdBasicBindingTests {
- @Test
- public void testBinding(ServiceRegistryScope scope) {
- final SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) new MetadataSources( scope.getRegistry() )
- .addResource( "org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.hbm.xml" )
- .buildMetadata()
- .buildSessionFactory();
-
- try {
- final EntityPersister entityDescriptor = sessionFactory.getRuntimeMetamodels()
- .getMappingMetamodel()
- .findEntityDescriptor( "DynamicCompositeIdBasic" );
-
- assertThat( entityDescriptor.getNumberOfAttributeMappings(), is( 1 ) );
-
- final EntityIdentifierMapping identifierMapping = entityDescriptor.getIdentifierMapping();
- assertThat( identifierMapping, instanceOf( EmbeddedIdentifierMappingImpl.class ) );
- final EmbeddedIdentifierMappingImpl cid = (EmbeddedIdentifierMappingImpl) identifierMapping;
- assertThat( cid.getEmbeddableTypeDescriptor().getNumberOfAttributeMappings(), is( 2 ) );
-
- final AttributeMapping key1 = cid.getEmbeddableTypeDescriptor().findAttributeMapping( "key1" );
- assertThat( key1, notNullValue() );
-
- final AttributeMapping key2 = cid.getEmbeddableTypeDescriptor().findAttributeMapping( "key2" );
- assertThat( key2, notNullValue() );
-
- final AttributeMapping attr1 = entityDescriptor.findAttributeMapping( "attr1" );
- assertThat( attr1, notNullValue() );
- }
- finally {
- sessionFactory.close();
- }
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicTests.java
new file mode 100644
index 000000000000..25add6b53275
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicTests.java
@@ -0,0 +1,70 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.bootstrap.binding.hbm.cid.nonaggregated.dynamic;
+
+import org.hibernate.cfg.AvailableSettings;
+import org.hibernate.metamodel.mapping.AttributeMapping;
+import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
+import org.hibernate.metamodel.mapping.NonAggregatedIdentifierMapping;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.ServiceRegistry;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.hibernate.testing.orm.junit.Setting;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * @author Steve Ebersole
+ */
+@SuppressWarnings("JUnitMalformedDeclaration")
+@ServiceRegistry(
+ settings = @Setting( name = AvailableSettings.HBM2DDL_AUTO, value = "create-drop" )
+)
+@DomainModel( xmlMappings = "org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.xml")
+@SessionFactory
+public class DynamicCompositeIdBasicTests {
+ @Test
+ void testBinding(SessionFactoryScope factoryScope) {
+ final EntityPersister entityDescriptor = factoryScope.getSessionFactory()
+ .getRuntimeMetamodels()
+ .getMappingMetamodel()
+ .findEntityDescriptor( "DynamicCompositeIdBasic" );
+
+ assertThat( entityDescriptor.getNumberOfAttributeMappings(), is( 1 ) );
+
+ final EntityIdentifierMapping identifierMapping = entityDescriptor.getIdentifierMapping();
+ assertThat( identifierMapping, instanceOf( NonAggregatedIdentifierMapping.class ) );
+ final NonAggregatedIdentifierMapping cid = (NonAggregatedIdentifierMapping) identifierMapping;
+ assertThat( cid.getEmbeddableTypeDescriptor().getNumberOfAttributeMappings(), is( 2 ) );
+
+ final AttributeMapping key1 = cid.getEmbeddableTypeDescriptor().findAttributeMapping( "key1" );
+ assertThat( key1, notNullValue() );
+
+ final AttributeMapping key2 = cid.getEmbeddableTypeDescriptor().findAttributeMapping( "key2" );
+ assertThat( key2, notNullValue() );
+
+ final AttributeMapping attr1 = entityDescriptor.findAttributeMapping( "attr1" );
+ assertThat( attr1, notNullValue() ); }
+
+ @Test
+ public void testFullQueryReference(SessionFactoryScope scope) {
+ scope.inTransaction(
+ session -> session.createQuery( "from DynamicCompositeIdBasic e where e.id.key1 = 1" ).list()
+ );
+ }
+
+ @Test
+ public void testEmbeddedQueryReference(SessionFactoryScope scope) {
+ scope.inTransaction(
+ session -> session.createQuery( "from DynamicCompositeIdBasic e where e.key1 = 1" ).list()
+ );
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicUsageTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicUsageTests.java
deleted file mode 100644
index c0e248d4e43a..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasicUsageTests.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.bootstrap.binding.hbm.cid.nonaggregated.dynamic;
-
-import org.hibernate.cfg.AvailableSettings;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.FailureExpected;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-/**
- * @author Steve Ebersole
- */
-@ServiceRegistry(
- settings = @Setting( name = AvailableSettings.HBM2DDL_AUTO, value = "create-drop" )
-)
-@DomainModel( xmlMappings = "org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.hbm.xml" )
-@SessionFactory
-public class DynamicCompositeIdBasicUsageTests {
- @Test
- public void testFullQueryReference(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> session.createQuery( "from DynamicCompositeIdBasic e where e.id.key1 = 1" ).list()
- );
- }
-
- @Test
- @FailureExpected( reason = "Do we want to allow this?" )
- public void testEmbeddedQueryReference(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> session.createQuery( "from DynamicCompositeIdBasic e where e.key1 = 1" ).list()
- );
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOneBindingTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOneBindingTests.java
deleted file mode 100644
index 70b140fc9bb8..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOneBindingTests.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.bootstrap.binding.hbm.cid.nonaggregated.dynamic;
-
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.metamodel.mapping.AttributeMapping;
-import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
-import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
-import org.hibernate.metamodel.mapping.internal.EmbeddedIdentifierMappingImpl;
-import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
-import org.hibernate.persister.entity.EntityPersister;
-
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * Note that this test uses a composite-id with key-many-to-one as part of a
- * dynamic model, which is the main construct needed by hibernate-envers
- *
- * @author Steve Ebersole
- */
-@ServiceRegistry(
- settings = @Setting( name = AvailableSettings.HBM2DDL_AUTO, value = "create-drop" )
-)
-public class DynamicCompositeIdManyToOneBindingTests {
- @Test
- public void testBinding(ServiceRegistryScope scope) {
- final SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) new MetadataSources( scope.getRegistry() )
- .addResource( "org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.hbm.xml" )
- .buildMetadata()
- .buildSessionFactory();
-
- try {
- final EntityPersister entityDescriptor = sessionFactory.getRuntimeMetamodels()
- .getMappingMetamodel()
- .findEntityDescriptor( "DynamicCompositeIdManyToOne" );
-
- assertThat( entityDescriptor.getNumberOfAttributeMappings(), is( 1 ) );
-
- final EntityIdentifierMapping identifierMapping = entityDescriptor.getIdentifierMapping();
- assertThat( identifierMapping, instanceOf( EmbeddedIdentifierMappingImpl.class ) );
- final EmbeddedIdentifierMappingImpl cid = (EmbeddedIdentifierMappingImpl) identifierMapping;
- assertThat( cid.getEmbeddableTypeDescriptor().getNumberOfAttributeMappings(), is( 2 ) );
-
- final AttributeMapping key1 = cid.getEmbeddableTypeDescriptor().findAttributeMapping( "key1" );
- assertThat( key1, notNullValue() );
- assertThat( key1, instanceOf( BasicAttributeMapping.class ) );
-
- final AttributeMapping key2 = cid.getEmbeddableTypeDescriptor().findAttributeMapping( "key2" );
- assertThat( key2, notNullValue() );
- assertThat( key2, instanceOf( ToOneAttributeMapping.class ) );
-
- final AttributeMapping attr1 = entityDescriptor.findAttributeMapping( "attr1" );
- assertThat( attr1, notNullValue() );
- assertThat( attr1, instanceOf( BasicAttributeMapping.class ) );
- }
- finally {
- sessionFactory.close();
- }
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOneTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOneTests.java
new file mode 100644
index 000000000000..5e47c1d23a8a
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOneTests.java
@@ -0,0 +1,88 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.bootstrap.binding.hbm.cid.nonaggregated.dynamic;
+
+import org.hibernate.cfg.AvailableSettings;
+import org.hibernate.metamodel.mapping.AttributeMapping;
+import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
+import org.hibernate.metamodel.mapping.NonAggregatedIdentifierMapping;
+import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
+import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
+import org.hibernate.persister.entity.EntityPersister;
+
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.ServiceRegistry;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.hibernate.testing.orm.junit.Setting;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * Note that this test uses a composite-id with key-many-to-one as part of a
+ * dynamic model, which is the main construct needed by hibernate-envers
+ *
+ * @author Steve Ebersole
+ */
+@SuppressWarnings("JUnitMalformedDeclaration")
+@ServiceRegistry(
+ settings = @Setting( name = AvailableSettings.HBM2DDL_AUTO, value = "create-drop" )
+)
+@DomainModel( xmlMappings = "org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.xml")
+@SessionFactory
+public class DynamicCompositeIdManyToOneTests {
+ @Test
+ void testBinding(SessionFactoryScope factoryScope) {
+ final EntityPersister entityDescriptor = factoryScope.getSessionFactory()
+ .getRuntimeMetamodels()
+ .getMappingMetamodel()
+ .findEntityDescriptor( "DynamicCompositeIdManyToOne" );
+
+ assertThat( entityDescriptor.getNumberOfAttributeMappings(), is( 1 ) );
+
+ final EntityIdentifierMapping identifierMapping = entityDescriptor.getIdentifierMapping();
+ assertThat( identifierMapping, instanceOf( NonAggregatedIdentifierMapping.class ) );
+ final NonAggregatedIdentifierMapping cid = (NonAggregatedIdentifierMapping) identifierMapping;
+ assertThat( cid.getEmbeddableTypeDescriptor().getNumberOfAttributeMappings(), is( 2 ) );
+
+ final AttributeMapping key1 = cid.getEmbeddableTypeDescriptor().findAttributeMapping( "key1" );
+ assertThat( key1, notNullValue() );
+ assertThat( key1, instanceOf( BasicAttributeMapping.class ) );
+
+ final AttributeMapping key2 = cid.getEmbeddableTypeDescriptor().findAttributeMapping( "key2" );
+ assertThat( key2, notNullValue() );
+ assertThat( key2, instanceOf( ToOneAttributeMapping.class ) );
+
+ final AttributeMapping attr1 = entityDescriptor.findAttributeMapping( "attr1" );
+ assertThat( attr1, notNullValue() );
+ assertThat( attr1, instanceOf( BasicAttributeMapping.class ) );
+ }
+
+ @Test
+ public void testFullQueryReference(SessionFactoryScope scope) {
+ scope.inTransaction(
+ (session) -> {
+ session.createQuery( "select e from DynamicCompositeIdManyToOne e" ).list();
+ session.createQuery( "select e from DynamicCompositeIdManyToOne e where e.id.key1 = 1" ).list();
+ session.createQuery( "select e from DynamicCompositeIdManyToOne e where e.id.key2.name = 'abc'" ).list();
+ }
+ );
+ }
+
+ @Test
+ public void testEmbeddedQueryReference(SessionFactoryScope scope) {
+ scope.inTransaction(
+ (session) -> {
+ session.createQuery( "select e from DynamicCompositeIdManyToOne e" ).list();
+ session.createQuery( "select e from DynamicCompositeIdManyToOne e where e.key1 = 1" ).list();
+ session.createQuery( "select e from DynamicCompositeIdManyToOne e where e.key2.name = 'abc'" ).list();
+ }
+ );
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOneUsageTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOneUsageTests.java
deleted file mode 100644
index b15d0720add6..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOneUsageTests.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.bootstrap.binding.hbm.cid.nonaggregated.dynamic;
-
-import org.hibernate.cfg.AvailableSettings;
-
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.FailureExpected;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-/**
- * Note that this test uses a composite-id with key-many-to-one as part of a
- * dynamic model, which is the main construct needed by hibernate-envers
- *
- * @author Steve Ebersole
- */
-@ServiceRegistry(
- settings = @Setting( name = AvailableSettings.HBM2DDL_AUTO, value = "create-drop" )
-)
-@DomainModel( xmlMappings = "org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.hbm.xml" )
-@SessionFactory
-public class DynamicCompositeIdManyToOneUsageTests {
- @Test
- public void testFullQueryReference(SessionFactoryScope scope) {
- scope.inTransaction(
- (session) -> {
- session.createQuery( "select e__ from DynamicCompositeIdManyToOne e__" ).list();
- session.createQuery( "select e__ from DynamicCompositeIdManyToOne e__ where e__.id.key1 = 1" ).list();
- session.createQuery( "select e__ from DynamicCompositeIdManyToOne e__ where e__.id.key2.name = 'abc'" ).list();
- }
- );
- }
-
- @Test
- @FailureExpected( reason = "Do we want to allow this?" )
- public void testEmbeddedQueryReference(SessionFactoryScope scope) {
- scope.inTransaction(
- (session) -> {
- session.createQuery( "select e__ from DynamicCompositeIdManyToOne e__" ).list();
- session.createQuery( "select e__ from DynamicCompositeIdManyToOne e__ where e__.key1 = 1" ).list();
- session.createQuery( "select e__ from DynamicCompositeIdManyToOne e__ where e__.key2.name = 'abc'" ).list();
- }
- );
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicHbmTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicHbmTests.java
deleted file mode 100644
index 2d6a34637796..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicHbmTests.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.bootstrap.binding.hbm.simple.dynamic;
-
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.metamodel.mapping.AttributeMapping;
-import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping;
-import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
-import org.hibernate.persister.entity.EntityPersister;
-
-import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
-import org.hibernate.testing.orm.junit.Setting;
-import org.junit.jupiter.api.Test;
-
-import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-/**
- * @author Steve Ebersole
- */
-@ServiceRegistry(
- settings = @Setting( name = AvailableSettings.HBM2DDL_AUTO, value = "create-drop" )
-)
-public class SimpleDynamicHbmTests {
- @Test
- public void testBinding(ServiceRegistryScope scope) {
- final SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) new MetadataSources( scope.getRegistry() )
- .addResource( "org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicEntity.hbm.xml" )
- .buildMetadata()
- .buildSessionFactory();
-
- try {
- final EntityPersister entityDescriptor = sessionFactory.getRuntimeMetamodels()
- .getMappingMetamodel()
- .findEntityDescriptor( "SimpleDynamicEntity" );
-
- final EntityIdentifierMapping identifierMapping = entityDescriptor.getIdentifierMapping();
- assertThat( identifierMapping, instanceOf( BasicEntityIdentifierMapping.class ) );
- final BasicEntityIdentifierMapping bid = (BasicEntityIdentifierMapping) identifierMapping;
- assertThat( bid.getFetchableName(), is( "id" ) );
- assertThat( bid.getPartName(), is( EntityIdentifierMapping.ID_ROLE_NAME ) );
-
- assertThat( entityDescriptor.getNumberOfAttributeMappings(), is( 1 ) );
- assertThat( entityDescriptor.getNumberOfDeclaredAttributeMappings(), is( 1 ) );
- final AttributeMapping nameAttr = entityDescriptor.findAttributeMapping( "name" );
- assertThat( nameAttr, notNullValue() );
-
- sessionFactory.inTransaction(
- session -> {
- session.createQuery( "from SimpleDynamicEntity" ).list();
- session.createQuery( "select e from SimpleDynamicEntity e" ).list();
- session.createQuery( "select e from SimpleDynamicEntity e where e.name = 'abc'" ).list();
- }
- );
- }
- finally {
- sessionFactory.close();
- }
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicXmlTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicXmlTests.java
new file mode 100644
index 000000000000..229e58233e6d
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicXmlTests.java
@@ -0,0 +1,64 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.bootstrap.binding.hbm.simple.dynamic;
+
+import org.hibernate.cfg.AvailableSettings;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.metamodel.mapping.AttributeMapping;
+import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping;
+import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
+import org.hibernate.persister.entity.EntityPersister;
+
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.ServiceRegistry;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.hibernate.testing.orm.junit.Setting;
+import org.junit.jupiter.api.Test;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+/**
+ * @author Steve Ebersole
+ */
+@SuppressWarnings("JUnitMalformedDeclaration")
+@ServiceRegistry(
+ settings = @Setting( name = AvailableSettings.HBM2DDL_AUTO, value = "create-drop" )
+)
+@DomainModel(xmlMappings = "org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicEntity.xml")
+@SessionFactory
+public class SimpleDynamicXmlTests {
+ @Test
+ public void testBinding(SessionFactoryScope factoryScope) {
+ final SessionFactoryImplementor sessionFactory = factoryScope.getSessionFactory();
+
+ final EntityPersister entityDescriptor = sessionFactory.getRuntimeMetamodels()
+ .getMappingMetamodel()
+ .findEntityDescriptor( "SimpleDynamicEntity" );
+
+ final EntityIdentifierMapping identifierMapping = entityDescriptor.getIdentifierMapping();
+ assertThat( identifierMapping, instanceOf( BasicEntityIdentifierMapping.class ) );
+ final BasicEntityIdentifierMapping bid = (BasicEntityIdentifierMapping) identifierMapping;
+ assertThat( bid.getFetchableName(), is( "id" ) );
+ assertThat( bid.getPartName(), is( EntityIdentifierMapping.ID_ROLE_NAME ) );
+
+ assertThat( entityDescriptor.getNumberOfAttributeMappings(), is( 1 ) );
+ assertThat( entityDescriptor.getNumberOfDeclaredAttributeMappings(), is( 1 ) );
+ final AttributeMapping nameAttr = entityDescriptor.findAttributeMapping( "name" );
+ assertThat( nameAttr, notNullValue() );
+ }
+
+ @Test
+ public void testUsage(SessionFactoryScope factoryScope) {
+ factoryScope.inTransaction( (session) -> {
+ session.createQuery( "from SimpleDynamicEntity" ).list();
+ session.createQuery( "select e from SimpleDynamicEntity e" ).list();
+ session.createQuery( "select e from SimpleDynamicEntity e where e.name = 'abc'" ).list();
+ } );
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimpleHbmTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimplePojoXmlTests.java
similarity index 61%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimpleHbmTests.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimplePojoXmlTests.java
index 433ade179646..b8c789ead02f 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimpleHbmTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimplePojoXmlTests.java
@@ -4,15 +4,18 @@
*/
package org.hibernate.orm.test.bootstrap.binding.hbm.simple.pojo;
-import org.hibernate.boot.MetadataSources;
+import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.ServiceRegistry;
-import org.hibernate.testing.orm.junit.ServiceRegistryScope;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
@@ -23,14 +26,16 @@
/**
* @author Steve Ebersole
*/
-@ServiceRegistry
-public class SimpleHbmTests {
+@SuppressWarnings("JUnitMalformedDeclaration")
+@ServiceRegistry(
+ settings = @Setting( name = AvailableSettings.HBM2DDL_AUTO, value = "create-drop" )
+)
+@DomainModel(xmlMappings = "org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimpleEntity.xml")
+@SessionFactory
+public class SimplePojoXmlTests {
@Test
- public void testBinding(ServiceRegistryScope scope) {
- final SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) new MetadataSources( scope.getRegistry() )
- .addResource( "org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimpleEntity.hbm.xml" )
- .buildMetadata()
- .buildSessionFactory();
+ public void testBinding(SessionFactoryScope factoryScope) {
+ final SessionFactoryImplementor sessionFactory = factoryScope.getSessionFactory();
final EntityPersister entityDescriptor = sessionFactory.getRuntimeMetamodels()
.getMappingMetamodel()
@@ -47,4 +52,13 @@ public void testBinding(ServiceRegistryScope scope) {
final AttributeMapping nameAttr = entityDescriptor.findAttributeMapping( "name" );
assertThat( nameAttr, notNullValue() );
}
+
+ @Test
+ void testUsage(SessionFactoryScope factoryScope) {
+ factoryScope.inTransaction( (session) -> {
+ session.createQuery( "from SimpleEntity" ).list();
+ session.createQuery( "select e from SimpleEntity e" ).list();
+ session.createQuery( "select e from SimpleEntity e where e.name = 'abc'" ).list();
+ } );
+ }
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/HBMManyToOneAnnotationMissingPrimaryKeyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/HBMManyToOneAnnotationMissingPrimaryKeyTest.java
deleted file mode 100644
index d8588228bcde..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/HBMManyToOneAnnotationMissingPrimaryKeyTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.bootstrap.binding.mixed;
-
-import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * https://hibernate.atlassian.net/browse/HHH-11502
- *
- * @author Russ Tennant (russ@venturetech.net)
- */
-public class HBMManyToOneAnnotationMissingPrimaryKeyTest extends BaseNonConfigCoreFunctionalTestCase
-{
- @Override
- protected Class[] getAnnotatedClasses() {
- return new Class[]{
- AnnotationEntity.class
- };
- }
-
- @Override
- protected String[] getMappings() {
- return new String[]{
- "HBMEntity.hbm.xml"
- };
- }
-
- @Override
- protected String getBaseForMappings() {
- return "/org/hibernate/orm/test/bootstrap/binding/mixed/";
- }
-
- /**
- * Test to trigger the NullPointerException in the ModelBinder.
- * @throws Exception on error.
- */
- @Test
- public void hhh11502() throws Exception {
- Assert.assertTrue(true);
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/MixedMappingPkFkTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/MixedMappingPkFkTests.java
new file mode 100644
index 000000000000..96f8620c7540
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/MixedMappingPkFkTests.java
@@ -0,0 +1,29 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.bootstrap.binding.mixed;
+
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.DomainModelScope;
+import org.hibernate.testing.orm.junit.Jira;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author Russ Tennant (russ@venturetech.net)
+ */
+@SuppressWarnings("JUnitMalformedDeclaration")
+@Jira( "https://hibernate.atlassian.net/browse/HHH-11502" )
+@DomainModel(
+ annotatedClasses = AnnotationEntity.class,
+ xmlMappings = "/org/hibernate/orm/test/bootstrap/binding/mixed/XmlEntity.xml"
+)
+public class MixedMappingPkFkTests {
+ @Test
+ void testMapping(DomainModelScope modelScope) {
+ // just trigger the build
+ assertThat( modelScope.getDomainModel() ).isNotNull();
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/XMLMappingDisabledTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/XMLMappingDisabledTest.java
index 6ee674b61a99..e5b1e9d5efe1 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/XMLMappingDisabledTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/XMLMappingDisabledTest.java
@@ -4,47 +4,29 @@
*/
package org.hibernate.orm.test.bootstrap.binding.mixed;
-import java.util.Map;
-
-import org.hibernate.cfg.AvailableSettings;
-
-import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
-import org.junit.Test;
+import org.hibernate.boot.MetadataSources;
+import org.hibernate.cfg.MappingSettings;
+import org.hibernate.testing.orm.junit.ServiceRegistry;
+import org.hibernate.testing.orm.junit.ServiceRegistryScope;
+import org.hibernate.testing.orm.junit.Setting;
+import org.junit.jupiter.api.Test;
/**
* Verifies that setting org.hibernate.cfg.AvailableSettings#XML_MAPPING_ENABLED to
* false actually ignores the mapping files.
*/
-public class XMLMappingDisabledTest extends BaseNonConfigCoreFunctionalTestCase {
+@SuppressWarnings("JUnitMalformedDeclaration")
+@ServiceRegistry(settings = @Setting(name= MappingSettings.XML_MAPPING_ENABLED, value = "false"))
+public class XMLMappingDisabledTest {
@Test
- public void xmlMappedEntityIsIgnored() throws Exception {
- // If this booted we're good: the XML mapping used in this test is invalid.
- }
-
- @Override
- protected Class[] getAnnotatedClasses() {
- return new Class[] {
- AnnotationEntity.class,
- HBMEntity.class
- };
- }
-
- @Override
- protected String[] getMappings() {
- return new String[] {
- "HBMEntity.hbm.xml"
- };
+ public void xmlMappedEntityIsIgnored(ServiceRegistryScope registryScope) throws Exception {
+ final MetadataSources metadataSources = new MetadataSources( registryScope.getRegistry() )
+ .addAnnotatedClasses( AnnotationEntity.class, XmlEntity.class )
+ .addResource( "org/hibernate/orm/test/bootstrap/binding/hbm/BadMapping.xml" );
+
+ // even though BadMapping.xml is invalid, this should be ok
+ // because we disabled XML processing
+ metadataSources.buildMetadata();
}
-
- @Override
- protected String getBaseForMappings() {
- return "/org/hibernate/orm/test/bootstrap/binding/mixed/";
- }
-
- @Override
- protected void addSettings(Map settings) {
- settings.put( AvailableSettings.XML_MAPPING_ENABLED, "false" );
- }
-
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/HBMEntity.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/XmlEntity.java
similarity index 94%
rename from hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/HBMEntity.java
rename to hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/XmlEntity.java
index 4b41f1766739..f0f6131af804 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/HBMEntity.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bootstrap/binding/mixed/XmlEntity.java
@@ -4,7 +4,7 @@
*/
package org.hibernate.orm.test.bootstrap.binding.mixed;
-public class HBMEntity {
+public class XmlEntity {
private long _id;
private AnnotationEntity _association;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/InvocationTargetExceptionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/InvocationTargetExceptionTest.java
index b6d262be6fbe..dcd4de1523bd 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/InvocationTargetExceptionTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/InvocationTargetExceptionTest.java
@@ -4,56 +4,48 @@
*/
package org.hibernate.orm.test.bytecode;
-import java.text.ParseException;
-
import org.hibernate.Hibernate;
-import org.hibernate.Session;
-
-import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-
-public class InvocationTargetExceptionTest extends BaseCoreFunctionalTestCase {
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
- @Override
- protected String getBaseForMappings() {
- return "org/hibernate/orm/test/";
- }
+import java.text.ParseException;
- @Override
- public String[] getMappings() {
- return new String[] { "bytecode/Bean.hbm.xml" };
- }
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.fail;
+@SuppressWarnings("JUnitMalformedDeclaration")
+@DomainModel(xmlMappings = "org/hibernate/orm/test/bytecode/Bean.xml")
+@SessionFactory
+public class InvocationTargetExceptionTest {
@Test
- public void testProxiedInvocationException() {
- Session s = openSession();
- s.beginTransaction();
- Bean bean = new Bean();
- bean.setSomeString( "my-bean" );
- s.persist( bean );
- s.getTransaction().commit();
- s.close();
-
- s = openSession();
- s.beginTransaction();
- bean = ( Bean ) s.getReference( Bean.class, bean.getSomeString() );
- assertFalse( Hibernate.isInitialized( bean ) );
- try {
- bean.throwException();
- fail( "exception not thrown" );
- }
- catch ( ParseException e ) {
- // expected behavior
- }
- catch ( Throwable t ) {
- fail( "unexpected exception type : " + t );
- }
+ public void testProxiedInvocationException(SessionFactoryScope factoryScope) {
+ factoryScope.inTransaction( (s) -> {
+ Bean bean = new Bean();
+ bean.setSomeString( "my-bean" );
+ s.persist( bean );
+ } );
+
+ factoryScope.inTransaction( (s) -> {
+ Bean bean = s.getReference( Bean.class, "my-bean" );
+ assertThat( Hibernate.isInitialized( bean ) ).isFalse();
+ try {
+ bean.throwException();
+ fail( "exception not thrown" );
+ }
+ catch ( ParseException e ) {
+ // expected behavior
+ }
+ catch ( Throwable t ) {
+ fail( "unexpected exception type : " + t );
+ }
+ } );
+ }
- s.remove( bean );
- s.getTransaction().commit();
- s.close();
+ @AfterEach
+ public void dropTestData(SessionFactoryScope factoryScope) throws Exception {
+ factoryScope.dropData();
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/ProxyBean.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/ProxyBean.java
deleted file mode 100644
index bf45cf9fc0f6..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/ProxyBean.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.bytecode;
-
-
-/**
- * Created by IntelliJ IDEA.
- * User: Paul
- * Date: Mar 9, 2007
- * Time: 11:31:40 AM
- * To change this template use File | Settings | File Templates.
- */
-public class ProxyBean {
- private String someString;
- private long someLong;
-
-
- public String getSomeString() {
- return someString;
- }
-
- public void setSomeString(String someString) {
- this.someString = someString;
- }
-
-
- public long getSomeLong() {
- return someLong;
- }
-
- public void setSomeLong(long someLong) {
- this.someLong = someLong;
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/backref/BackrefCompositeMapKeyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/backref/BackrefCompositeMapKeyTest.java
deleted file mode 100644
index e4cc311e5800..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/bytecode/enhancement/lazy/backref/BackrefCompositeMapKeyTest.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.bytecode.enhancement.lazy.backref;
-
-import org.hibernate.Hibernate;
-import org.hibernate.LockMode;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.orm.test.bytecode.enhancement.lazy.NoDirtyCheckingContext;
-import org.hibernate.orm.test.bytecode.enhancement.lazy.proxy.inlinedirtychecking.DirtyCheckEnhancementContext;
-import org.hibernate.orm.test.collection.backref.map.compkey.MapKey;
-import org.hibernate.orm.test.collection.backref.map.compkey.Part;
-import org.hibernate.orm.test.collection.backref.map.compkey.Product;
-
-import org.hibernate.testing.bytecode.enhancement.CustomEnhancementContext;
-import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-
-/**
- * BackrefCompositeMapKeyTest implementation. Test access to a composite map-key
- * backref via a number of different access methods.
- *
- * @author Steve Ebersole
- */
-@DomainModel(
- xmlMappings = {
- "org/hibernate/orm/test/collection/backref/map/compkey/Mappings.hbm.xml"
- }
-)
-@SessionFactory
-@BytecodeEnhanced
-@CustomEnhancementContext({ NoDirtyCheckingContext.class, DirtyCheckEnhancementContext.class })
-public class BackrefCompositeMapKeyTest {
-
- @Test
- public void testOrphanDeleteOnDelete(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> {
- Product prod = new Product( "Widget" );
- Part part = new Part( "Widge", "part if a Widget" );
- MapKey mapKey = new MapKey( "Top" );
- prod.getParts().put( mapKey, part );
- Part part2 = new Part( "Get", "another part if a Widget" );
- prod.getParts().put( new MapKey( "Bottom" ), part2 );
- session.persist( prod );
- session.flush();
-
- prod.getParts().remove( mapKey );
-
- session.remove( prod );
- }
- );
-
- scope.inTransaction(
- session -> {
- assertNull( session.get( Part.class, "Widge" ), "Orphan 'Widge' was not deleted" );
- assertNull( session.get( Part.class, "Get" ), "Orphan 'Get' was not deleted" );
- assertNull( session.get( Product.class, "Widget" ), "Orphan 'Widget' was not deleted" );
- }
- );
- }
-
- @Test
- public void testOrphanDeleteAfterPersist(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> {
- Product prod = new Product( "Widget" );
- Part part = new Part( "Widge", "part if a Widget" );
- MapKey mapKey = new MapKey( "Top" );
- prod.getParts().put( mapKey, part );
- Part part2 = new Part( "Get", "another part if a Widget" );
- prod.getParts().put( new MapKey( "Bottom" ), part2 );
- session.persist( prod );
-
- prod.getParts().remove( mapKey );
- }
- );
-
- scope.inTransaction(
- session ->
- session.remove( session.get( Product.class, "Widget" ) )
- );
- }
-
- @Test
- public void testOrphanDeleteAfterPersistAndFlush(SessionFactoryScope scope) {
- scope.inTransaction(
- session -> {
- Product prod = new Product( "Widget" );
- Part part = new Part( "Widge", "part if a Widget" );
- MapKey mapKey = new MapKey( "Top" );
- prod.getParts().put( mapKey, part );
- Part part2 = new Part( "Get", "another part if a Widget" );
- prod.getParts().put( new MapKey( "Bottom" ), part2 );
- session.persist( prod );
- session.flush();
-
- prod.getParts().remove( mapKey );
- }
- );
-
- scope.inTransaction(
- session -> {
- assertNull( session.get( Part.class, "Widge" ) );
- assertNotNull( session.get( Part.class, "Get" ) );
- session.remove( session.get( Product.class, "Widget" ) );
- }
- );
-
- }
-
- @Test
- public void testCannotLockDetachedEntity(SessionFactoryScope scope) {
- Product prod = new Product( "Widget" );
- MapKey mapKey = new MapKey( "Top" );
- scope.inTransaction(
- session -> {
- Part part = new Part( "Widge", "part if a Widget" );
- prod.getParts().put( mapKey, part );
- Part part2 = new Part( "Get", "another part if a Widget" );
- prod.getParts().put( new MapKey( "Bottom" ), part2 );
- session.persist( prod );
- }
- );
-
-
- scope.inTransaction(
- session -> {
- assertThrows(IllegalArgumentException.class,
- () -> session.lock( prod, LockMode.READ ),
- "Given entity is not associated with the persistence context"
- );
- }
- );
-
- scope.inTransaction(
- session -> {
- assertNotNull( session.get( Part.class, "Widge" ) );
- assertNotNull( session.get( Part.class, "Get" ) );
- session.remove( session.get( Product.class, "Widget" ) );
- }
- );
- }
-
- @Test
- public void testOrphanDelete(SessionFactoryScope scope) {
- MapKey mapKey = new MapKey( "Top" );
- scope.inTransaction(
- session -> {
- Product prod = new Product( "Widget" );
- Part part = new Part( "Widge", "part if a Widget" );
- prod.getParts().put( mapKey, part );
- Part part2 = new Part( "Get", "another part if a Widget" );
- prod.getParts().put( new MapKey( "Bottom" ), part2 );
- session.persist( prod );
- }
- );
-
-
- SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
- sessionFactory.getCache().evictEntityData( Product.class );
- sessionFactory.getCache().evictEntityData( Part.class );
-
- scope.inTransaction(
- session -> {
- Product prod = session.get( Product.class, "Widget" );
- assertTrue( Hibernate.isInitialized( prod.getParts() ) );
- Part part = session.get( Part.class, "Widge" );
- prod.getParts().remove( mapKey );
- }
- );
-
-
- sessionFactory.getCache().evictEntityData( Product.class );
- sessionFactory.getCache().evictEntityData( Part.class );
-
- scope.inTransaction(
- session -> {
- Product prod = session.get( Product.class, "Widget" );
- assertTrue( Hibernate.isInitialized( prod.getParts() ) );
- assertNull( prod.getParts().get( new MapKey( "Top" ) ) );
- assertNotNull( session.get( Part.class, "Get" ) );
- session.remove( session.get( Product.class, "Widget" ) );
- }
- );
- }
-
- @Test
- public void testOrphanDeleteOnMerge(SessionFactoryScope scope) {
- Product prod = new Product( "Widget" );
- MapKey mapKey = new MapKey( "Top" );
- scope.inTransaction(
- session -> {
- Part part = new Part( "Widge", "part if a Widget" );
- prod.getParts().put( mapKey, part );
- Part part2 = new Part( "Get", "another part if a Widget" );
- prod.getParts().put( new MapKey( "Bottom" ), part2 );
- session.persist( prod );
- }
- );
-
-
- prod.getParts().remove( mapKey );
-
- scope.inTransaction(
- session ->
- session.merge( prod )
- );
-
- scope.inTransaction(
- session -> {
- assertNull( session.get( Part.class, "Widge" ) );
- assertNotNull( session.get( Part.class, "Get" ) );
- session.remove( session.get( Product.class, "Widget" ) );
- }
- );
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/CacheableFileTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/CacheableFileTest.java
deleted file mode 100644
index a5018cd4d7d3..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/CacheableFileTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.cfg;
-
-import java.io.File;
-
-import org.hibernate.cfg.Configuration;
-
-import org.hibernate.testing.junit4.BaseUnitTestCase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests using of cacheable configuration files.
- *
- * @author Steve Ebersole
- */
-public class CacheableFileTest extends BaseUnitTestCase {
- public static final String MAPPING = "org/hibernate/orm/test/cfg/Cacheable.hbm.xml";
-
- private File mappingFile;
- private File mappingBinFile;
-
- @Before
- public void setUp() throws Exception {
- mappingFile = new File( getClass().getClassLoader().getResource( MAPPING ).toURI() );
- assertTrue( mappingFile.exists() );
- mappingBinFile = new File( mappingFile.getParentFile(), mappingFile.getName() + ".bin" );
- if ( mappingBinFile.exists() ) {
- //noinspection ResultOfMethodCallIgnored
- mappingBinFile.delete();
- }
- }
-
- @After
- public void tearDown() throws Exception {
- if ( mappingBinFile != null && mappingBinFile.exists() ) {
- // be nice
- //noinspection ResultOfMethodCallIgnored
- mappingBinFile.delete();
- }
- mappingBinFile = null;
- mappingFile = null;
- }
-
- @Test
- public void testCachedFiles() throws Exception {
- assertFalse( mappingBinFile.exists() );
- // This call should create the cached file
- new Configuration().addCacheableFile( mappingFile );
- assertTrue( mappingBinFile.exists() );
-
- new Configuration().addCacheableFileStrictly( mappingFile );
-
- // make mappingBinFile obsolete by declaring it a minute older than mappingFile
- mappingBinFile.setLastModified( mappingFile.lastModified() - 60000L );
-
- new Configuration().addCacheableFile( mappingFile );
- assertTrue( mappingBinFile.exists() );
- assertTrue( "mappingFile should have been recreated.", mappingBinFile.lastModified() >= mappingFile.lastModified());
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/PropertyAccessTypeDetectionTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/PropertyAccessTypeDetectionTest.java
new file mode 100644
index 000000000000..a4f15035279b
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/PropertyAccessTypeDetectionTest.java
@@ -0,0 +1,50 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.cfg;
+
+import org.hibernate.metamodel.mapping.AttributeMapping;
+import org.hibernate.persister.entity.EntityPersister;
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.JiraKey;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * @author Chris Cranford
+ */
+@SuppressWarnings("JUnitMalformedDeclaration")
+@JiraKey(value ="HHH-12199")
+@DomainModel(xmlMappings = "org/hibernate/orm/test/cfg/FooEntity.xml")
+@SessionFactory
+public class PropertyAccessTypeDetectionTest {
+ public static class FooEntity {
+ public static final String intValue = "intValue";
+
+ private Long id;
+ private Integer _intValue;
+
+ public Long getId() { return id; }
+ public void setId(Long id) { this.id = id; }
+
+ public Integer getIntValue() { return _intValue; }
+ public void setIntValue(Integer intValue) { this._intValue = intValue; }
+ }
+
+ @Test
+ public void testPropertyAccessIgnoresStaticFields(SessionFactoryScope factoryScope) {
+ // verify that the entity persister is configured with property intValue as an Integer rather than
+ // using the static field reference and determining the type to be String.
+ final EntityPersister entityDescriptor = factoryScope
+ .getSessionFactory()
+ .getMappingMetamodel()
+ .getEntityDescriptor( FooEntity.class );
+ final AttributeMapping attributeMapping = entityDescriptor.findAttributeMapping( "intValue" );
+ assertThat( attributeMapping ).isNotNull();
+ assertThat( attributeMapping.getJavaType().getJavaTypeClass() ).isAssignableFrom( Integer.class );
+ }
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/PropertyAccessTypeDetectionType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/PropertyAccessTypeDetectionType.java
deleted file mode 100644
index f02a65f626da..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/PropertyAccessTypeDetectionType.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.cfg;
-
-import org.junit.Test;
-
-import org.hibernate.testing.orm.junit.JiraKey;
-import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
-
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Chris Cranford
- */
-@JiraKey(value ="HHH-12199")
-public class PropertyAccessTypeDetectionType extends BaseCoreFunctionalTestCase {
-
- @Override
- protected String getBaseForMappings() {
- return "org/hibernate/orm/test/";
- }
-
- @Override
- protected String[] getMappings() {
- return new String[] { "cfg/FooEntity.hbm.xml" };
- }
-
- public static class FooEntity {
- public static final String intValue = "intValue";
-
- private Long id;
- private Integer _intValue;
-
- public Long getId() { return id; }
- public void setId(Long id) { this.id = id; }
-
- public Integer getIntValue() { return _intValue; }
- public void setIntValue(Integer intValue) { this._intValue = intValue; }
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void testPropertyAccessIgnoresStaticFields() {
- // verify that the entity persister is configured with property intValue as an Integer rather than
- // using the static field reference and determining the type to be String.
- assertTrue(
- sessionFactory().getRuntimeMetamodels()
- .getMappingMetamodel()
- .getEntityDescriptor( FooEntity.class )
- .getPropertyType( "intValue" )
- .getReturnedClass()
- .isAssignableFrom( Integer.class )
- );
- }
-}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java
index 661e82123924..91511225b99f 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/collection/backref/map/compkey/BackrefCompositeMapKeyTest.java
@@ -8,9 +8,14 @@
import org.hibernate.LockMode;
import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.orm.test.bytecode.enhancement.lazy.NoDirtyCheckingContext;
+import org.hibernate.orm.test.bytecode.enhancement.lazy.proxy.inlinedirtychecking.DirtyCheckEnhancementContext;
+import org.hibernate.testing.bytecode.enhancement.CustomEnhancementContext;
+import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -20,17 +25,17 @@
/**
- * BackrefCompositeMapKeyTest implementation. Test access to a composite map-key
- * backref via a number of different access methods.
- *
* @author Steve Ebersole
*/
+@SuppressWarnings("JUnitMalformedDeclaration")
@DomainModel(
xmlMappings = (
- "org/hibernate/orm/test/collection/backref/map/compkey/Mappings.hbm.xml"
+ "org/hibernate/orm/test/collection/backref/map/compkey/Mappings.xml"
)
)
@SessionFactory
+@BytecodeEnhanced(runNotEnhancedAsWell = true)
+@CustomEnhancementContext({ NoDirtyCheckingContext.class, DirtyCheckEnhancementContext.class })
public class BackrefCompositeMapKeyTest {
@Test
@@ -54,9 +59,9 @@ public void testOrphanDeleteOnDelete(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
- assertNull( session.get( Part.class, "Widge" ), "Orphan 'Widge' was not deleted" );
- assertNull( session.get( Part.class, "Get" ), "Orphan 'Get' was not deleted" );
- assertNull( session.get( Product.class, "Widget" ), "Orphan 'Widget' was not deleted" );
+ assertNull( session.find( Part.class, "Widge" ), "Orphan 'Widge' was not deleted" );
+ assertNull( session.find( Part.class, "Get" ), "Orphan 'Get' was not deleted" );
+ assertNull( session.find( Product.class, "Widget" ), "Orphan 'Widget' was not deleted" );
}
);
}
@@ -102,9 +107,9 @@ public void testOrphanDeleteAfterPersistAndFlush(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
- assertNull( session.get( Part.class, "Widge" ) );
- assertNotNull( session.get( Part.class, "Get" ) );
- session.remove( session.get( Product.class, "Widget" ) );
+ assertNull( session.find( Part.class, "Widge" ) );
+ assertNotNull( session.find( Part.class, "Get" ) );
+ session.remove( session.find( Product.class, "Widget" ) );
}
);
@@ -136,9 +141,9 @@ public void testCannotLockDetachedEntity(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
- assertNotNull( session.get( Part.class, "Widge" ) );
- assertNotNull( session.get( Part.class, "Get" ) );
- session.remove( session.get( Product.class, "Widget" ) );
+ assertNotNull( session.find( Part.class, "Widge" ) );
+ assertNotNull( session.find( Part.class, "Get" ) );
+ session.remove( session.find( Product.class, "Widget" ) );
}
);
}
@@ -177,11 +182,11 @@ public void testOrphanDelete(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
- Product prod = session.get( Product.class, "Widget" );
+ Product prod = session.find( Product.class, "Widget" );
assertTrue( Hibernate.isInitialized( prod.getParts() ) );
assertNull( prod.getParts().get( new MapKey( "Top" ) ) );
- assertNotNull( session.get( Part.class, "Get" ) );
- session.remove( session.get( Product.class, "Widget" ) );
+ assertNotNull( session.find( Part.class, "Get" ) );
+ session.remove( session.find( Product.class, "Widget" ) );
}
);
}
@@ -210,10 +215,15 @@ public void testOrphanDeleteOnMerge(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
- assertNull( session.get( Part.class, "Widge" ) );
- assertNotNull( session.get( Part.class, "Get" ) );
- session.remove( session.get( Product.class, "Widget" ) );
+ assertNull( session.find( Part.class, "Widge" ) );
+ assertNotNull( session.find( Part.class, "Get" ) );
+ session.remove( session.find( Product.class, "Widget" ) );
}
);
}
+
+ @AfterEach
+ void dropTestData(SessionFactoryScope factoryScope) {
+ factoryScope.dropData();
+ }
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/collection/bag/PersistentBagTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/collection/bag/PersistentBagTest.java
index 1b2b76bd783e..b6a0adfcba05 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/collection/bag/PersistentBagTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/collection/bag/PersistentBagTest.java
@@ -4,21 +4,15 @@
*/
package org.hibernate.orm.test.collection.bag;
-import java.util.ArrayList;
-
-import org.hibernate.cfg.MappingSettings;
import org.hibernate.collection.spi.PersistentBag;
-
-import org.hibernate.testing.orm.junit.DialectFeatureChecks;
import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.RequiresDialectFeature;
-import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.hibernate.testing.orm.junit.Setting;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import java.util.ArrayList;
+
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -27,11 +21,8 @@
*
* @author Steve Ebersole
*/
-@ServiceRegistry(settings = @Setting(name = MappingSettings.TRANSFORM_HBM_XML, value = "true"))
-@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsNoColumnInsert.class)
-@DomainModel(
- xmlMappings = "org/hibernate/orm/test/collection/bag/Mappings.hbm.xml"
-)
+@SuppressWarnings("JUnitMalformedDeclaration")
+@DomainModel(xmlMappings = "org/hibernate/orm/test/collection/bag/Mappings.xml")
@SessionFactory
public class PersistentBagTest {
@@ -79,7 +70,6 @@ public void testWriteMethodDirtying(SessionFactoryScope scope) {
@Test
public void testMergePersistentEntityWithNewOneToManyElements(SessionFactoryScope scope) {
-
Long orderId = scope.fromTransaction(
session -> {
Order order = new Order();
@@ -100,16 +90,13 @@ public void testMergePersistentEntityWithNewOneToManyElements(SessionFactoryScop
item2.setName( "i2" );
order.addItem( item1 );
order.addItem( item2 );
- order = (Order) session.merge( order );
+ order = session.merge( order );
}
);
+ }
- scope.inTransaction(
- session -> {
- Order order = session.get( Order.class, orderId );
- assertEquals( 2, order.getItems().size() );
- session.remove( order );
- }
- );
+ @AfterEach
+ void dropTestData(SessionFactoryScope factoryScope) {
+ factoryScope.dropData();
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/dynamicmap/CustomEntityNameResolverTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/dynamicmap/CustomEntityNameResolverTest.java
index 7771d44c2576..258cf75baf9d 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/dynamicmap/CustomEntityNameResolverTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/dynamicmap/CustomEntityNameResolverTest.java
@@ -4,44 +4,65 @@
*/
package org.hibernate.orm.test.dynamicmap;
-import java.util.HashMap;
-import java.util.Map;
-
import org.hibernate.EntityNameResolver;
-import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.cfg.Configuration;
+import org.hibernate.boot.spi.MetadataImplementor;
+import org.hibernate.cfg.SchemaToolingSettings;
import org.hibernate.engine.spi.SessionFactoryImplementor;
-
+import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.Jira;
+import org.hibernate.testing.orm.junit.ServiceRegistry;
+import org.hibernate.testing.orm.junit.SessionFactoryExtension;
+import org.hibernate.testing.orm.junit.SessionFactoryProducer;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.hibernate.testing.orm.junit.SessionFactoryScopeParameterResolver;
+import org.hibernate.testing.orm.junit.Setting;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+
+import java.util.HashMap;
+import java.util.Map;
-import static org.hibernate.testing.transaction.TransactionUtil2.inTransaction;
-import static org.hibernate.tool.schema.Action.ACTION_CREATE_THEN_DROP;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Marco Belladelli
*/
@Jira( "https://hibernate.atlassian.net/browse/HHH-18486" )
-public class CustomEntityNameResolverTest {
+@ServiceRegistry(settings = @Setting(name = SchemaToolingSettings.HBM2DDL_AUTO, value = "create-drop") )
+@DomainModel(xmlMappings = "org/hibernate/orm/test/dynamicmap/artist.xml")
+@ExtendWith( SessionFactoryExtension.class )
+@ExtendWith( SessionFactoryScopeParameterResolver.class )
+public class CustomEntityNameResolverTest implements SessionFactoryProducer {
+ @AfterEach
+ void dropTestData(SessionFactoryScope factoryScope) {
+ factoryScope.dropData();
+ }
+
@Test
- public void test() {
- final Configuration configuration = new Configuration();
- configuration.setProperty( AvailableSettings.HBM2DDL_AUTO, ACTION_CREATE_THEN_DROP );
- configuration.setProperty( AvailableSettings.SHOW_SQL, Boolean.TRUE.toString() );
- configuration.setProperty( AvailableSettings.FORMAT_SQL, Boolean.TRUE.toString() );
- configuration.addResource( "org/hibernate/orm/test/dynamicmap/artist.hbm.xml" );
- configuration.addEntityNameResolver( new HibernateEntityNameResolver() );
- try (final SessionFactoryImplementor sf = (SessionFactoryImplementor) configuration.buildSessionFactory()) {
- inTransaction( sf, session -> {
- final Map artistEntity = new HashMap<>();
- artistEntity.put( "id", 1 );
- artistEntity.put( "firstname", "John" );
- artistEntity.put( "lastname", "Doe" );
- // Persist the dynamic map entity
- session.persist( artistEntity );
- } );
- sf.getSchemaManager().truncateMappedObjects();
- }
+ public void test(SessionFactoryScope factoryScope) {
+ // Persist the dynamic map entity
+ factoryScope.inTransaction( (session) -> {
+ final Map artistEntity = new HashMap<>();
+ artistEntity.put( "id", 1 );
+ artistEntity.put( "name", "John Doe" );
+ session.persist( artistEntity );
+ } );
+
+ factoryScope.inTransaction( (session) -> {
+ //noinspection unchecked
+ final Map loaded = (Map) session.byId( "artist" ).load( 1 );
+ assertThat( loaded ).isNotNull();
+ assertThat( loaded.get( "$type$" ) ).isEqualTo( "artist" );
+ } );
+ }
+
+
+ @Override
+ public SessionFactoryImplementor produceSessionFactory(MetadataImplementor model) {
+ return (SessionFactoryImplementor) model.getSessionFactoryBuilder()
+ .addEntityNameResolver( new HibernateEntityNameResolver() )
+ .build();
}
static class HibernateEntityNameResolver implements EntityNameResolver {
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/dynamicmap/DynamicMapTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/dynamicmap/DynamicMapTest.java
index 0a870cf826ab..0b9f53e92767 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/dynamicmap/DynamicMapTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/dynamicmap/DynamicMapTest.java
@@ -20,7 +20,7 @@
@JiraKey(value = "HHH-12539")
@DomainModel(
- xmlMappings = "org/hibernate/orm/test/dynamicmap/Test.hbm.xml"
+ xmlMappings = "org/hibernate/orm/test/dynamicmap/Test.xml"
)
@SessionFactory
public class DynamicMapTest {
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/dynamicmap/MixedModelTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/dynamicmap/MixedModelTests.java
new file mode 100644
index 000000000000..cffb224593f0
--- /dev/null
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/dynamicmap/MixedModelTests.java
@@ -0,0 +1,13 @@
+/*
+ * SPDX-License-Identifier: Apache-2.0
+ * Copyright Red Hat Inc. and Hibernate Authors
+ */
+package org.hibernate.orm.test.dynamicmap;
+
+/**
+ * Tests for models which mix dynamic and non-dynamic classes.
+ *
+ * @author Steve Ebersole
+ */
+public class MixedModelTests {
+}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ASTParserLoadingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ASTParserLoadingTest.java
index eb21a67273f2..2ad603699601 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ASTParserLoadingTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ASTParserLoadingTest.java
@@ -27,10 +27,10 @@
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.internal.EmbeddedSqmPathSource;
import org.hibernate.metamodel.model.domain.internal.EntitySqmPathSource;
-import org.hibernate.orm.test.any.hbm.IntegerPropertyValue;
-import org.hibernate.orm.test.any.hbm.PropertySet;
-import org.hibernate.orm.test.any.hbm.PropertyValue;
-import org.hibernate.orm.test.any.hbm.StringPropertyValue;
+import org.hibernate.orm.test.any.xml.IntegerPropertyValue;
+import org.hibernate.orm.test.any.xml.PropertySet;
+import org.hibernate.orm.test.any.xml.PropertyValue;
+import org.hibernate.orm.test.any.xml.StringPropertyValue;
import org.hibernate.orm.test.cid.Customer;
import org.hibernate.orm.test.cid.LineItem;
import org.hibernate.orm.test.cid.LineItem.Id;
@@ -110,7 +110,7 @@
"/org/hibernate/orm/test/cid/Order.hbm.xml",
"/org/hibernate/orm/test/cid/LineItem.hbm.xml",
"/org/hibernate/orm/test/cid/Product.hbm.xml",
- "/org/hibernate/orm/test/any/hbm/Properties.hbm.xml",
+ "/org/hibernate/orm/test/any/xml/Properties.xml",
"/org/hibernate/orm/test/legacy/Commento.hbm.xml",
"/org/hibernate/orm/test/legacy/Marelo.hbm.xml"
},
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/metamodel/AbstractJpaMetamodelPopulationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/metamodel/AbstractJpaMetamodelPopulationTest.java
index 72904d6a3983..36bf17d57ef7 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/metamodel/AbstractJpaMetamodelPopulationTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/metamodel/AbstractJpaMetamodelPopulationTest.java
@@ -58,7 +58,7 @@ public static class CompositeIdId implements Serializable {
@Override
protected String[] getMappings() {
return new String[] {
- "org/hibernate/jpa/test/metamodel/SimpleEntity.hbm.xml",
+ "org/hibernate/jpa/test/metamodel/SimpleEntity.xml",
"org/hibernate/jpa/test/metamodel/CompositeIdEntity.hbm.xml",
"org/hibernate/jpa/test/metamodel/CompositeId2Entity.hbm.xml"
};
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchTest.java
index be7f3bd6f0f6..de09706d8c34 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchTest.java
@@ -4,14 +4,15 @@
*/
package org.hibernate.orm.test.mapping.fetch.subselect;
-import java.util.List;
-
+import jakarta.persistence.criteria.CriteriaBuilder;
+import jakarta.persistence.criteria.CriteriaQuery;
+import jakarta.persistence.criteria.Root;
import org.hibernate.Hibernate;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.collection.spi.PersistentCollection;
-
import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.NotImplementedYet;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
@@ -20,10 +21,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import jakarta.persistence.criteria.CriteriaBuilder;
-import jakarta.persistence.criteria.CriteriaQuery;
-import jakarta.persistence.criteria.JoinType;
-import jakarta.persistence.criteria.Root;
+import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -33,16 +31,16 @@
/**
* @author Gavin King
*/
+@SuppressWarnings("JUnitMalformedDeclaration")
@ServiceRegistry(
settings = {
@Setting( name = AvailableSettings.GENERATE_STATISTICS, value = "true" ),
@Setting( name = AvailableSettings.USE_SECOND_LEVEL_CACHE, value = "false" )
}
)
-@DomainModel(
- xmlMappings = "/mappings/subselectfetch/ParentChild.hbm.xml"
-)
+@DomainModel(xmlMappings = "/mappings/subselectfetch/parent-child.xml")
@SessionFactory( useCollectingStatementInspector = true )
+@NotImplementedYet(reason = "SUBSELECT fetch defined in mapping.xml not working - https://hibernate.atlassian.net/browse/HHH-19316")
public class SubselectFetchTest {
@BeforeEach
public void prepareTestData(SessionFactoryScope scope) {
@@ -281,24 +279,48 @@ public void testSubselectFetchWithLimit(SessionFactoryScope scope) {
}
@Test
- public void testManyToManyCriteriaJoin(SessionFactoryScope scope) {
- scope.inTransaction(
- s -> {
- CriteriaBuilder criteriaBuilder = s.getCriteriaBuilder();
- CriteriaQuery criteria = criteriaBuilder.createQuery( Parent.class );
- Root root = criteria.from( Parent.class );
- root.join( "moreChildren", JoinType.INNER )
- .join( "friends", JoinType.INNER );
- criteria.orderBy( criteriaBuilder.desc( root.get( "name" ) ) );
-
- s.createQuery( criteria ).list();
-
- criteria = criteriaBuilder.createQuery( Parent.class );
- root = criteria.from( Parent.class );
- root.fetch( "moreChildren", JoinType.LEFT ).fetch( "friends", JoinType.LEFT );
- criteria.orderBy( criteriaBuilder.desc( root.get( "name" ) ) );
+ void testCriteria(SessionFactoryScope scope) {
+ final SQLStatementInspector sqlCollector = scope.getCollectingStatementInspector();
+ sqlCollector.clear();
+ scope.inTransaction( (session) -> {
+ CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
+ CriteriaQuery criteria = criteriaBuilder.createQuery( Parent.class );
+ Root root = criteria.from( Parent.class );
+ criteria.where( criteriaBuilder.isNotNull( root.get( "name" ) ) );
+ criteria.orderBy( criteriaBuilder.desc( root.get( "name" ) ) );
+
+ final List results = session.createQuery( criteria ).list();
+ assertThat( results ).hasSize( 2 );
+ assertThat( sqlCollector.getSqlQueries() ).hasSize( 1 );
+
+ sqlCollector.clear();
+ boolean firstPass = true;
+ for ( Parent result : results ) {
+ if ( firstPass ) {
+ firstPass = false;
+
+ assertThat( Hibernate.isInitialized( result.getChildren() ) ).isFalse();
+ assertThat( Hibernate.isInitialized( result.getMoreChildren() ) ).isFalse();
+
+ // trigger initialization
+ result.getChildren().size();
+ result.getMoreChildren().size();
+
+ assertThat( Hibernate.isInitialized( result.getChildren() ) ).isTrue();
+ assertThat( Hibernate.isInitialized( result.getMoreChildren() ) ).isTrue();
+
+ // make sure the fetch happened by subselect
+ assertThat( sqlCollector.getSqlQueries() ).hasSize( 2 );
+ assertThat( sqlCollector.getSqlQueries().get( 0 ) ).contains( ".name is not null" );
+ assertThat( sqlCollector.getSqlQueries().get( 1 ) ).contains( ".name is not null" );
}
- );
+ else {
+ // the subselect fetch triggered from first-pass should have initialized all
+ assertThat( Hibernate.isInitialized( result.getChildren() ) ).isTrue();
+ assertThat( Hibernate.isInitialized( result.getMoreChildren() ) ).isTrue();
+ }
+ }
+ } );
}
@Test
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchWithFormulaTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchWithFormulaTest.java
index 3306cc2beba3..3513e54469b9 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchWithFormulaTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchWithFormulaTest.java
@@ -4,57 +4,46 @@
*/
package org.hibernate.orm.test.mapping.fetch.subselect;
-import java.util.List;
-
-import jakarta.persistence.criteria.CriteriaBuilder;
-import jakarta.persistence.criteria.CriteriaQuery;
-
import org.hibernate.community.dialect.FirebirdDialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseDialect;
import org.hibernate.mapping.Collection;
+import org.hibernate.testing.jdbc.SQLStatementInspector;
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.DomainModelScope;
+import org.hibernate.testing.orm.junit.FailureExpected;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.hibernate.testing.orm.junit.SkipForDialect;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import org.hibernate.testing.SkipForDialect;
-import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
-import static org.junit.Assert.assertThat;
-
-@SkipForDialect(SQLServerDialect.class)
-@SkipForDialect(SybaseDialect.class)
-@SkipForDialect(FirebirdDialect.class)
-public class SubselectFetchWithFormulaTest extends BaseNonConfigCoreFunctionalTestCase {
- @Override
- protected String getBaseForMappings() {
- return "";
- }
+import java.util.List;
- @Override
- protected String[] getMappings() {
- return new String[] {
- "mappings/subselectfetch/Name.hbm.xml",
- "mappings/subselectfetch/Value.hbm.xml"
- };
- }
+import static org.assertj.core.api.Assertions.assertThat;
- @Before
- public void before() {
- doInHibernate( this::sessionFactory, session -> {
- Name chris = new Name();
+@SuppressWarnings("JUnitMalformedDeclaration")
+@SkipForDialect(dialectClass = SQLServerDialect.class)
+@SkipForDialect(dialectClass = SybaseDialect.class)
+@SkipForDialect(dialectClass = FirebirdDialect.class)
+@DomainModel(xmlMappings = {"mappings/subselectfetch/name.xml", "mappings/subselectfetch/value.xml"})
+@SessionFactory(useCollectingStatementInspector = true)
+@FailureExpected(reason = "https://hibernate.atlassian.net/browse/HHH-19316")
+public class SubselectFetchWithFormulaTest {
+ static void prepareTestData(SessionFactoryScope factoryScope) {
+ factoryScope.inTransaction( (session) -> {
+ final Name chris = new Name();
chris.setId( 1 );
chris.setName( "chris" );
- Value cat = new Value();
+ final Value cat = new Value();
cat.setId(1);
cat.setName( chris );
cat.setValue( "cat" );
- Value canary = new Value();
+ final Value canary = new Value();
canary.setId( 2 );
canary.setName( chris );
canary.setValue( "canary" );
@@ -63,16 +52,16 @@ public void before() {
session.persist( cat );
session.persist( canary );
- Name sam = new Name();
+ final Name sam = new Name();
sam.setId(2);
sam.setName( "sam" );
- Value seal = new Value();
+ final Value seal = new Value();
seal.setId( 3 );
seal.setName( sam );
seal.setValue( "seal" );
- Value snake = new Value();
+ final Value snake = new Value();
snake.setId( 4 );
snake.setName( sam );
snake.setValue( "snake" );
@@ -80,41 +69,43 @@ public void before() {
session.persist( sam );
session.persist(seal);
session.persist( snake );
-
} );
}
- @After
- public void after() {
- inTransaction(
- session -> {
- session.createQuery( "delete Value" ).executeUpdate();
- session.createQuery( "delete Name" ).executeUpdate();
- }
- );
+ @BeforeEach
+ void createTestData(SessionFactoryScope factoryScope) {
+ prepareTestData( factoryScope );
}
+ @AfterEach
+ void dropTestData(SessionFactoryScope factoryScope) {
+ factoryScope.dropData();
+ }
@Test
- public void checkSubselectWithFormula() throws Exception {
+ public void checkSubselectWithFormula(DomainModelScope modelScope, SessionFactoryScope factoryScope) {
+ verify( modelScope, factoryScope );
+
+ }
+
+ static void verify(DomainModelScope modelScope, SessionFactoryScope factoryScope) {
// as a pre-condition make sure that subselect fetching is enabled for the collection...
- Collection collectionBinding = metadata().getCollectionBinding( Name.class.getName() + ".values" );
- assertThat( collectionBinding.isSubselectLoadable(), is( true ) );
+ Collection collectionBinding = modelScope.getDomainModel().getCollectionBinding( Name.class.getName() + ".values" );
+ assertThat( collectionBinding.isSubselectLoadable() ).isTrue();
+
// Now force the subselect fetch and make sure we do not get SQL errors
- inTransaction(
- session -> {
- CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
- CriteriaQuery criteria = criteriaBuilder.createQuery( Name.class );
- criteria.from( Name.class );
- List results = session.createQuery( criteria ).list();
-// List results = session.createCriteria(Name.class).list();
- for (Name name : results) {
- name.getValues().size();
- }
- }
- );
+ factoryScope.inTransaction( (session) -> {
+ final SQLStatementInspector sqlCollector = factoryScope.getCollectingStatementInspector();
+ final List names = session.createSelectionQuery( "from Name", Name.class ).list();
+ sqlCollector.clear();
+
+ names.forEach( (name) -> {
+ assertThat( name.getValues() ).hasSize( 2 );
+ } );
+ assertThat( sqlCollector.getSqlQueries() ).hasSize( 1 );
+ } );
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchWithFormulaTransactSqlTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchWithFormulaTransactSqlTest.java
index adb13c24c9fb..e1f69baa8c69 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchWithFormulaTransactSqlTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/fetch/subselect/SubselectFetchWithFormulaTransactSqlTest.java
@@ -4,107 +4,42 @@
*/
package org.hibernate.orm.test.mapping.fetch.subselect;
-import java.util.List;
-import jakarta.persistence.criteria.CriteriaBuilder;
-import jakarta.persistence.criteria.CriteriaQuery;
-
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.dialect.SybaseDialect;
-import org.hibernate.mapping.Collection;
-
-import org.hibernate.testing.RequiresDialect;
-import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
+import org.hibernate.testing.orm.junit.DomainModel;
+import org.hibernate.testing.orm.junit.DomainModelScope;
+import org.hibernate.testing.orm.junit.FailureExpected;
+import org.hibernate.testing.orm.junit.RequiresDialect;
+import org.hibernate.testing.orm.junit.SessionFactory;
+import org.hibernate.testing.orm.junit.SessionFactoryScope;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.hibernate.orm.test.mapping.fetch.subselect.SubselectFetchWithFormulaTest.prepareTestData;
+import static org.hibernate.orm.test.mapping.fetch.subselect.SubselectFetchWithFormulaTest.verify;
+
+@SuppressWarnings("JUnitMalformedDeclaration")
@RequiresDialect(SQLServerDialect.class)
@RequiresDialect(SybaseDialect.class)
-public class SubselectFetchWithFormulaTransactSqlTest extends BaseNonConfigCoreFunctionalTestCase {
- @Override
- protected String getBaseForMappings() {
- return "";
- }
-
- @Override
- protected String[] getMappings() {
- return new String[] {
- "mappings/subselectfetch/NameTransactSql.hbm.xml",
- "mappings/subselectfetch/Value.hbm.xml"
- };
+@DomainModel(xmlMappings = {"mappings/subselectfetch/name-tsql.xml", "mappings/subselectfetch/value.xml"})
+@SessionFactory(useCollectingStatementInspector = true)
+@FailureExpected(reason = "https://hibernate.atlassian.net/browse/HHH-19316")
+public class SubselectFetchWithFormulaTransactSqlTest {
+
+ @BeforeEach
+ void createTestData(SessionFactoryScope factoryScope) {
+ prepareTestData( factoryScope );
}
- @Before
- public void before() {
- inTransaction(
- session -> {
- Name chris = new Name();
- chris.setId( 1 );
- chris.setName( "chris" );
- Value cat = new Value();
- cat.setId(1);
- cat.setName( chris );
- cat.setValue( "cat" );
- Value canary = new Value();
- canary.setId( 2 );
- canary.setName( chris );
- canary.setValue( "canary" );
-
- session.persist( chris );
- session.persist( cat );
- session.persist( canary );
-
- Name sam = new Name();
- sam.setId(2);
- sam.setName( "sam" );
- Value seal = new Value();
- seal.setId( 3 );
- seal.setName( sam );
- seal.setValue( "seal" );
- Value snake = new Value();
- snake.setId( 4 );
- snake.setName( sam );
- snake.setValue( "snake" );
-
- session.persist( sam );
- session.persist(seal);
- session.persist( snake );
- }
- );
- }
-
- @After
- public void after() {
- inTransaction(
- session -> {
- session.createQuery( "delete Value" ).executeUpdate();
- session.createQuery( "delete Name" ).executeUpdate();
- }
- );
+ @AfterEach
+ void dropTestData(SessionFactoryScope factoryScope) {
+ factoryScope.dropData();
}
@Test
- public void checkSubselectWithFormula() throws Exception {
- // as a pre-condition make sure that subselect fetching is enabled for the collection...
- Collection collectionBinding = metadata().getCollectionBinding( Name.class.getName() + ".values" );
- assertThat( collectionBinding.isSubselectLoadable(), is( true ) );
-
- // Now force the subselect fetch and make sure we do not get SQL errors
- inTransaction(
- session -> {
- CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder();
- CriteriaQuery criteria = criteriaBuilder.createQuery( Name.class );
- criteria.from( Name.class );
- List results = session.createQuery( criteria ).list();
-// List results = session.createCriteria(Name.class).list();
- for (Name name : results) {
- name.getValues().size();
- }
- }
- );
+ public void checkSubselectWithFormula(DomainModelScope modelScope, SessionFactoryScope factoryScope) {
+ verify( modelScope, factoryScope );
}
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/type/typedef/NamedEnumUserTypeTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/type/typedef/NamedEnumUserTypeTest.java
deleted file mode 100644
index 36ffc5e4af25..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/type/typedef/NamedEnumUserTypeTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * SPDX-License-Identifier: Apache-2.0
- * Copyright Red Hat Inc. and Hibernate Authors
- */
-package org.hibernate.orm.test.mapping.type.typedef;
-
-import org.hibernate.orm.test.mapping.converted.enums.Gender;
-import org.hibernate.orm.test.mapping.converted.enums.HairColor;
-import org.hibernate.orm.test.mapping.converted.enums.Person;
-
-
-import org.hibernate.testing.orm.junit.JiraKey;
-import org.hibernate.testing.orm.junit.DomainModel;
-import org.hibernate.testing.orm.junit.SessionFactory;
-import org.hibernate.testing.orm.junit.SessionFactoryScope;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-/**
- * Tests that the same UserType class used in multiple distinct TypeDefinitions
- * get distinct ManagedBeans.
- *
- * NOTE : this is with no local parameter
- *
- * @author gtoison
- */
-@DomainModel(
- xmlMappings = "mappings/type/custom/typedef/PersonNamedEnumsUserType.xml"
-)
-@SessionFactory
-public class NamedEnumUserTypeTest {
- @Test
- @JiraKey(value = "HHH-14820")
- public void testNamedEnumUserType(SessionFactoryScope scope) {
- scope.inTransaction( (session) -> {
- session.createQuery( "from Person p", Person.class ).list();
- } );
- }
-
- @BeforeEach
- public void createTestData(SessionFactoryScope scope) {
- scope.inTransaction( (session) -> {
- session.persist( Person.person( Gender.MALE, HairColor.BLACK ) );
- } );
- }
-
- @AfterEach
- public void dropTestData(SessionFactoryScope scope) {
- scope.inTransaction( (session) -> {
- session.createQuery( "delete Person" ).executeUpdate();
- } );
- }
-}
diff --git a/hibernate-core/src/test/resources/mappings/hbm/basic.xml b/hibernate-core/src/test/resources/mappings/hbm/basic.xml
deleted file mode 100644
index 3912d49cc3b8..000000000000
--- a/hibernate-core/src/test/resources/mappings/hbm/basic.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/hbm/simple.xml b/hibernate-core/src/test/resources/mappings/hbm/simple.xml
deleted file mode 100644
index 9b47517816b7..000000000000
--- a/hibernate-core/src/test/resources/mappings/hbm/simple.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/mappings/models/column/transform/hbm.xml b/hibernate-core/src/test/resources/mappings/models/column/transform/hbm.xml
deleted file mode 100644
index ebb6116b9f3f..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/column/transform/hbm.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/complete/discriminator-value.xml b/hibernate-core/src/test/resources/mappings/models/complete/discriminator-value.xml
index 1e61c5340ae0..4cc297d5e7a0 100644
--- a/hibernate-core/src/test/resources/mappings/models/complete/discriminator-value.xml
+++ b/hibernate-core/src/test/resources/mappings/models/complete/discriminator-value.xml
@@ -15,9 +15,7 @@
-
-
-
+
diff --git a/hibernate-core/src/test/resources/mappings/models/dynamic/dynamic-named-entity-graph.xml b/hibernate-core/src/test/resources/mappings/models/dynamic/dynamic-named-entity-graph.xml
index cbd4e42487d7..f283c269ade8 100644
--- a/hibernate-core/src/test/resources/mappings/models/dynamic/dynamic-named-entity-graph.xml
+++ b/hibernate-core/src/test/resources/mappings/models/dynamic/dynamic-named-entity-graph.xml
@@ -18,13 +18,13 @@
- integer
+ Integer
- string
+ String
- string
+ String
@@ -32,10 +32,10 @@
- integer
+ Integer
- string
+ String
diff --git a/hibernate-core/src/test/resources/mappings/models/dynamic/dynamic-semi-simple.xml b/hibernate-core/src/test/resources/mappings/models/dynamic/dynamic-semi-simple.xml
index 18882b976de4..de67d375a4af 100644
--- a/hibernate-core/src/test/resources/mappings/models/dynamic/dynamic-semi-simple.xml
+++ b/hibernate-core/src/test/resources/mappings/models/dynamic/dynamic-semi-simple.xml
@@ -11,7 +11,7 @@
Integer
BIGINT
-
+
@@ -26,10 +26,10 @@
- string
+ java.lang.String
- string
+ java.lang.String
diff --git a/hibernate-core/src/test/resources/mappings/models/dynamic/dynamic-typing.xml b/hibernate-core/src/test/resources/mappings/models/dynamic/dynamic-typing.xml
new file mode 100644
index 000000000000..27cc2bf7f98a
--- /dev/null
+++ b/hibernate-core/src/test/resources/mappings/models/dynamic/dynamic-typing.xml
@@ -0,0 +1,69 @@
+
+
+
+
+
+
+
+
+
+ java.lang.Integer
+
+
+
+ boolean
+
+
+
+ String
+
+
+
+ int
+
+
+
+ Integer
+
+
+ java.net.URL
+
+
+ java.sql.Clob
+
+
+ java.time.Instant
+
+
+ DATE
+
+
+ TIME
+
+
+ TIMESTAMP
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/entityname/hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/entityname/hbm.xml
deleted file mode 100644
index 69697dafa0f9..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/entityname/hbm.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/extends/discriminated-separate.xml b/hibernate-core/src/test/resources/mappings/models/hbm/extends/discriminated-separate.xml
index bcb415b4ace3..1ec54b9521fc 100644
--- a/hibernate-core/src/test/resources/mappings/models/hbm/extends/discriminated-separate.xml
+++ b/hibernate-core/src/test/resources/mappings/models/hbm/extends/discriminated-separate.xml
@@ -1,22 +1,30 @@
+
-
-
-
-
+
+
+ Branch
+ L
+
-
-
+
+ Root
+ B
+
-
-
-
-
-
-
\ No newline at end of file
+
+
+ R
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/extends/discriminated-structured.xml b/hibernate-core/src/test/resources/mappings/models/hbm/extends/discriminated-structured.xml
deleted file mode 100644
index ba9482ac5001..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/extends/discriminated-structured.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/intf/mapped-interface.hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/intf/mapped-interface.hbm.xml
deleted file mode 100644
index aa446e5197d3..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/intf/mapped-interface.hbm.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/inverse/hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/inverse/hbm.xml
deleted file mode 100644
index 8f22cf0e9eb1..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/inverse/hbm.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/join/hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/join/hbm.xml
deleted file mode 100644
index d507ac9db578..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/join/hbm.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/joinformula/many-to-one-join-column-and-formula.xml b/hibernate-core/src/test/resources/mappings/models/hbm/joinformula/many-to-one-join-column-and-formula.xml
deleted file mode 100644
index 7e7887c05df2..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/joinformula/many-to-one-join-column-and-formula.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 'MAILING'
-
-
-
-
- 'SHIPPING'
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/list/hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/list/hbm.xml
deleted file mode 100644
index ec707ef6c44f..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/list/hbm.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/list/mapping.xml b/hibernate-core/src/test/resources/mappings/models/hbm/list/mapping.xml
new file mode 100644
index 000000000000..d2145aa86834
--- /dev/null
+++ b/hibernate-core/src/test/resources/mappings/models/hbm/list/mapping.xml
@@ -0,0 +1,66 @@
+
+
+
+
+
+ org.hibernate.orm.test.boot.models.hbm.collections.list
+ FIELD
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/mappedsuper/implied-mapped-super.xml b/hibernate-core/src/test/resources/mappings/models/hbm/mappedsuper/implied-mapped-super.xml
deleted file mode 100644
index c4f86bcbb01a..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/mappedsuper/implied-mapped-super.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/notfound/Person2.hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/notfound/Person2.hbm.xml
deleted file mode 100644
index b5dde1552169..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/notfound/Person2.hbm.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/inverse/mapping.xml b/hibernate-core/src/test/resources/mappings/models/hbm/notfound/mapping.xml
similarity index 50%
rename from hibernate-core/src/test/resources/mappings/models/hbm/inverse/mapping.xml
rename to hibernate-core/src/test/resources/mappings/models/hbm/notfound/mapping.xml
index 1fc2fa23d1f2..1ec277de9a5e 100644
--- a/hibernate-core/src/test/resources/mappings/models/hbm/inverse/mapping.xml
+++ b/hibernate-core/src/test/resources/mappings/models/hbm/notfound/mapping.xml
@@ -5,30 +5,26 @@
~ Copyright Red Hat Inc. and Hibernate Authors
-->
-
-
- org.hibernate.orm.test.boot.models.hbm.inverse
+
+ org.hibernate.orm.test.boot.models.hbm.notfound
FIELD
-
-
+
-
+
+
+
-
-
+
-
-
-
-
+
-
-
-
+
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/properties/standard.hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/properties/standard.hbm.xml
deleted file mode 100644
index b4952f93bbfa..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/properties/standard.hbm.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/composite-many-to-one.hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/composite-many-to-one.hbm.xml
deleted file mode 100644
index 1bcc116c0360..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/composite-many-to-one.hbm.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/many-to-one.hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/many-to-one.hbm.xml
deleted file mode 100644
index d4d141f59271..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/many-to-one.hbm.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/properties.hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/properties.hbm.xml
deleted file mode 100644
index 8dbe01b4a7ec..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/properties.hbm.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/ref-many-to-one.hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/ref-many-to-one.hbm.xml
deleted file mode 100644
index dcb29fc37270..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/ref-many-to-one.hbm.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/ref-one-to-one.hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/ref-one-to-one.hbm.xml
deleted file mode 100644
index 7cceab2ea10e..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/propertyref/ref-one-to-one.hbm.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/transform2/person.hbm.xml b/hibernate-core/src/test/resources/mappings/models/hbm/transform2/person.hbm.xml
deleted file mode 100644
index 3a8c6a22b0f3..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/transform2/person.hbm.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/transform2/person.xml b/hibernate-core/src/test/resources/mappings/models/hbm/transform2/person.xml
deleted file mode 100644
index e6fe6873c3d8..000000000000
--- a/hibernate-core/src/test/resources/mappings/models/hbm/transform2/person.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/type/basics.xml b/hibernate-core/src/test/resources/mappings/models/hbm/type/basics.xml
index 51a4ce8d30d6..2e0dc17bb379 100644
--- a/hibernate-core/src/test/resources/mappings/models/hbm/type/basics.xml
+++ b/hibernate-core/src/test/resources/mappings/models/hbm/type/basics.xml
@@ -1,26 +1,32 @@
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DATE
+
+
+ TIME
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/type/element-collections.xml b/hibernate-core/src/test/resources/mappings/models/hbm/type/element-collections.xml
index 970d120cc320..2b685df81318 100644
--- a/hibernate-core/src/test/resources/mappings/models/hbm/type/element-collections.xml
+++ b/hibernate-core/src/test/resources/mappings/models/hbm/type/element-collections.xml
@@ -1,45 +1,58 @@
+
-
-
-
-
-
+
+ FIELD
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/join/mapping.xml b/hibernate-core/src/test/resources/mappings/models/join/mapping.xml
similarity index 100%
rename from hibernate-core/src/test/resources/mappings/models/hbm/join/mapping.xml
rename to hibernate-core/src/test/resources/mappings/models/join/mapping.xml
diff --git a/hibernate-core/src/test/resources/mappings/models/joinformula/many-to-one-join-column-and-formula.xml b/hibernate-core/src/test/resources/mappings/models/joinformula/many-to-one-join-column-and-formula.xml
new file mode 100644
index 000000000000..884bfc7bcc24
--- /dev/null
+++ b/hibernate-core/src/test/resources/mappings/models/joinformula/many-to-one-join-column-and-formula.xml
@@ -0,0 +1,31 @@
+
+
+
+ org.hibernate.orm.test.boot.models.hbm.joinformula
+
+
+
+
+
+
+ 'MAILING'
+
+
+
+ 'SHIPPING'
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/joinformula/many-to-one.xml b/hibernate-core/src/test/resources/mappings/models/joinformula/many-to-one.xml
similarity index 100%
rename from hibernate-core/src/test/resources/mappings/models/hbm/joinformula/many-to-one.xml
rename to hibernate-core/src/test/resources/mappings/models/joinformula/many-to-one.xml
diff --git a/hibernate-core/src/test/resources/mappings/models/hbm/joinformula/one-to-one.xml b/hibernate-core/src/test/resources/mappings/models/joinformula/one-to-one.xml
similarity index 100%
rename from hibernate-core/src/test/resources/mappings/models/hbm/joinformula/one-to-one.xml
rename to hibernate-core/src/test/resources/mappings/models/joinformula/one-to-one.xml
diff --git a/hibernate-core/src/test/resources/mappings/subselectfetch/Name.hbm.xml b/hibernate-core/src/test/resources/mappings/subselectfetch/Name.hbm.xml
deleted file mode 100644
index d63f56ac1f1f..000000000000
--- a/hibernate-core/src/test/resources/mappings/subselectfetch/Name.hbm.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/mappings/subselectfetch/NameTransactSql.hbm.xml b/hibernate-core/src/test/resources/mappings/subselectfetch/NameTransactSql.hbm.xml
deleted file mode 100644
index 1c130f7d0847..000000000000
--- a/hibernate-core/src/test/resources/mappings/subselectfetch/NameTransactSql.hbm.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/mappings/subselectfetch/ParentChild.hbm.xml b/hibernate-core/src/test/resources/mappings/subselectfetch/ParentChild.hbm.xml
deleted file mode 100644
index 12919612be10..000000000000
--- a/hibernate-core/src/test/resources/mappings/subselectfetch/ParentChild.hbm.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/mappings/subselectfetch/Value.hbm.xml b/hibernate-core/src/test/resources/mappings/subselectfetch/Value.hbm.xml
deleted file mode 100644
index d38eb04b22f4..000000000000
--- a/hibernate-core/src/test/resources/mappings/subselectfetch/Value.hbm.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/mappings/subselectfetch/name-tsql.xml b/hibernate-core/src/test/resources/mappings/subselectfetch/name-tsql.xml
new file mode 100644
index 000000000000..09123ecb12d0
--- /dev/null
+++ b/hibernate-core/src/test/resources/mappings/subselectfetch/name-tsql.xml
@@ -0,0 +1,24 @@
+
+
+
+ org.hibernate.orm.test.mapping.fetch.subselect
+ FIELD
+
+
+
+
+
+
+
+ (select len(c_name) from t_names where id = t_names.id)
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/mappings/subselectfetch/name.xml b/hibernate-core/src/test/resources/mappings/subselectfetch/name.xml
new file mode 100644
index 000000000000..61f4904ff117
--- /dev/null
+++ b/hibernate-core/src/test/resources/mappings/subselectfetch/name.xml
@@ -0,0 +1,24 @@
+
+
+
+ org.hibernate.orm.test.mapping.fetch.subselect
+ FIELD
+
+
+
+
+
+
+
+ (select length(sub.c_name) from t_names sub where c_id = sub.c_id)
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/mappings/subselectfetch/parent-child.xml b/hibernate-core/src/test/resources/mappings/subselectfetch/parent-child.xml
new file mode 100644
index 000000000000..a0e8d3b94bde
--- /dev/null
+++ b/hibernate-core/src/test/resources/mappings/subselectfetch/parent-child.xml
@@ -0,0 +1,47 @@
+
+
+
+ org.hibernate.orm.test.mapping.fetch.subselect
+ FIELD
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/mappings/subselectfetch/value.xml b/hibernate-core/src/test/resources/mappings/subselectfetch/value.xml
new file mode 100644
index 000000000000..4310a150b2e6
--- /dev/null
+++ b/hibernate-core/src/test/resources/mappings/subselectfetch/value.xml
@@ -0,0 +1,26 @@
+
+
+
+ org.hibernate.orm.test.mapping.fetch.subselect
+ FIELD
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/mappings/type/custom/typedef/PersonNamedEnumsUserType.xml b/hibernate-core/src/test/resources/mappings/type/custom/typedef/PersonNamedEnumsUserType.xml
deleted file mode 100644
index f742af4287c5..000000000000
--- a/hibernate-core/src/test/resources/mappings/type/custom/typedef/PersonNamedEnumsUserType.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
- org.hibernate.orm.test.mapping.converted.enums.Gender
-
-
- org.hibernate.orm.test.mapping.converted.enums.HairColor
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/jpa/test/metamodel/SimpleEntity.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/jpa/test/metamodel/SimpleEntity.hbm.xml
deleted file mode 100644
index 90ce76999e09..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/jpa/test/metamodel/SimpleEntity.hbm.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/jpa/test/metamodel/SimpleEntity.xml b/hibernate-core/src/test/resources/org/hibernate/jpa/test/metamodel/SimpleEntity.xml
new file mode 100644
index 000000000000..43b0ca57e05c
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/jpa/test/metamodel/SimpleEntity.xml
@@ -0,0 +1,20 @@
+
+
+
+ org.hibernate.jpa.test.metamodel
+
+
+
+ Integer
+
+
+ String
+
+
+
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/abstractembeddedcomponents/cid/Mappings.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/abstractembeddedcomponents/cid/Mappings.hbm.xml
deleted file mode 100644
index b7d69d80c5fc..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/abstractembeddedcomponents/cid/Mappings.hbm.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/Mappings.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/Mappings.hbm.xml
deleted file mode 100644
index 4ef0802105e8..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/abstractembeddedcomponents/propertyref/Mappings.hbm.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/Boat.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/Boat.hbm.xml
deleted file mode 100644
index 867cf8f3209e..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/Boat.hbm.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/Ferry.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/Ferry.hbm.xml
deleted file mode 100644
index 027ea880ff9e..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/Ferry.hbm.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/bytecode/Hammer.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/bytecode/Hammer.hbm.xml
deleted file mode 100644
index a80a70e5bda5..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/bytecode/Hammer.hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/derivedidentities/e1/b/specjmapid/lazy/hbm_order.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/derivedidentities/e1/b/specjmapid/lazy/hbm_order.xml
deleted file mode 100644
index 05c160bdd10e..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/derivedidentities/e1/b/specjmapid/lazy/hbm_order.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/fetchprofile/mappings.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/fetchprofile/mappings.xml
similarity index 50%
rename from hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/fetchprofile/mappings.hbm.xml
rename to hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/fetchprofile/mappings.xml
index fc1972b1a868..812d775480f1 100644
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/fetchprofile/mappings.hbm.xml
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/fetchprofile/mappings.xml
@@ -3,12 +3,11 @@
~ SPDX-License-Identifier: Apache-2.0
~ Copyright Red Hat Inc. and Hibernate Authors
-->
-
-
-
+
+ org.hibernate.test.annotations.fetchprofile
-
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/hibernate.cfg.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/hibernate.cfg.xml
deleted file mode 100644
index c5e5fea0bec6..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/hibernate.cfg.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/A.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/A.hbm.xml
deleted file mode 100644
index 915717f2352d..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/A.hbm.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/B.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/B.hbm.xml
deleted file mode 100644
index 3a9c0c9994a2..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/B.hbm.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/CloudType.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/CloudType.hbm.xml
deleted file mode 100644
index 9cf98ccc82be..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/CloudType.hbm.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/Government.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/Government.hbm.xml
deleted file mode 100644
index 273e30b03678..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/Government.hbm.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/pre-parsed-hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/pre-parsed-hbm.xml
deleted file mode 100644
index 74288d87f698..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/xml/hbm/pre-parsed-hbm.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/hbm/AnyTestEagerPropertySet.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/hbm/AnyTestEagerPropertySet.hbm.xml
deleted file mode 100644
index 5e796633bc6a..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/hbm/AnyTestEagerPropertySet.hbm.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/hbm/AnyTestLazyPropertySet.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/hbm/AnyTestLazyPropertySet.hbm.xml
deleted file mode 100644
index 7d1ad5c68d75..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/hbm/AnyTestLazyPropertySet.hbm.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/hbm/Person.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/hbm/Person.hbm.xml
deleted file mode 100644
index 2d9826a96d65..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/hbm/Person.hbm.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/hbm/Properties.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/hbm/Properties.hbm.xml
deleted file mode 100644
index 7effda2de2be..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/hbm/Properties.hbm.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml/Person.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml/Person.xml
new file mode 100644
index 000000000000..c9602906e8fc
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml/Person.xml
@@ -0,0 +1,76 @@
+
+
+
+ org.hibernate.orm.test.any.xml
+
+
+
+
+
+
+
+
+
+
+ STRING
+
+ Address
+
+
+ Long
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml/Properties.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml/Properties.xml
new file mode 100644
index 000000000000..a5aa755e6689
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml/Properties.xml
@@ -0,0 +1,99 @@
+
+
+
+ org.hibernate.orm.test.any.xml
+
+
+
+
+
+
+
+
+
+ STRING
+
+ IntegerPropertyValue
+ StringPropertyValue
+ ComplexPropertyValue
+
+
+ long
+
+
+
+
+
+
+
+
+
+
+ STRING
+
+ IntegerPropertyValue
+ StringPropertyValue
+
+
+ Long
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml2/NamedAnyContainerEager.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml2/NamedAnyContainerEager.xml
new file mode 100644
index 000000000000..1933c65e7eb8
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml2/NamedAnyContainerEager.xml
@@ -0,0 +1,54 @@
+
+
+
+ org.hibernate.orm.test.any.xml2
+ FIELD
+
+
+
+
+
+
+
+
+ STRING
+
+ NamedIntegerProperty
+ NamedStringProperty
+
+
+ Integer
+
+
+
+
+
+
+
+
+ STRING
+
+ NamedIntegerProperty
+ NamedStringProperty
+
+
+ Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml2/NamedAnyContainerLazy.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml2/NamedAnyContainerLazy.xml
new file mode 100644
index 000000000000..b91e3d749f39
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml2/NamedAnyContainerLazy.xml
@@ -0,0 +1,53 @@
+
+
+
+ org.hibernate.orm.test.any.xml2
+ FIELD
+
+
+
+
+
+
+
+
+ STRING
+
+ NamedIntegerProperty
+ NamedStringProperty
+
+
+ Integer
+
+
+
+
+
+
+
+
+ STRING
+
+ NamedIntegerProperty
+ NamedStringProperty
+
+
+ Integer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml2/NamedProperties.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml2/NamedProperties.xml
new file mode 100644
index 000000000000..a1e3ecfb10e3
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/any/xml2/NamedProperties.xml
@@ -0,0 +1,34 @@
+
+
+
+ org.hibernate.orm.test.any.xml2
+ FIELD
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/array/A.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/array/A.hbm.xml
deleted file mode 100644
index 78b795b8d0da..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/array/A.hbm.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/array/A.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/array/A.xml
new file mode 100644
index 000000000000..b0dab7d96283
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/array/A.xml
@@ -0,0 +1,35 @@
+
+
+
+ org.hibernate.orm.test.array
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/batch/DataPoint.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/batch/DataPoint.hbm.xml
deleted file mode 100644
index 2ef8dfcf4ed2..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/batch/DataPoint.hbm.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/batch/DataPoint.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/batch/DataPoint.xml
new file mode 100644
index 000000000000..96a374553266
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/batch/DataPoint.xml
@@ -0,0 +1,32 @@
+
+
+
+ org.hibernate.orm.test.batch
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/BadMapping.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/BadMapping.xml
new file mode 100644
index 000000000000..f5d977acfed0
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/BadMapping.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cacheable/SimpleEntity.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cacheable/SimpleEntity.hbm.xml
deleted file mode 100644
index f3bb553660cd..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cacheable/SimpleEntity.hbm.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.hbm.xml
deleted file mode 100644
index 577858442ebe..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.hbm.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.xml
new file mode 100644
index 000000000000..2681e26ee7b4
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdBasic.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+ Integer
+
+
+ Integer
+
+
+ String
+
+
+
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.hbm.xml
deleted file mode 100644
index 8f68d4e6ac04..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.hbm.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.xml
new file mode 100644
index 000000000000..985683b0f355
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/cid/nonaggregated/dynamic/DynamicCompositeIdManyToOne.xml
@@ -0,0 +1,32 @@
+
+
+
+ org.hibernate.orm.test.bootstrap.binding.hbm.cid.nonaggregated.dynamic
+
+
+
+ Integer
+
+
+ String
+
+
+
+
+
+
+
+ Integer
+
+
+ String
+
+
+
+
+
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicEntity.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicEntity.hbm.xml
deleted file mode 100644
index 3b9472fdb8d6..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicEntity.hbm.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicEntity.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicEntity.xml
new file mode 100644
index 000000000000..a97d89ab7e08
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/simple/dynamic/SimpleDynamicEntity.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+ Integer
+
+
+ String
+
+
+
+
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimpleEntity.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimpleEntity.hbm.xml
deleted file mode 100644
index 522d96f57e0e..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimpleEntity.hbm.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimpleEntity.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimpleEntity.xml
new file mode 100644
index 000000000000..4e0565674c2c
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/hbm/simple/pojo/SimpleEntity.xml
@@ -0,0 +1,17 @@
+
+
+
+ org.hibernate.orm.test.bootstrap.binding.hbm.simple.pojo
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/mixed/HBMEntity.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/mixed/HBMEntity.hbm.xml
deleted file mode 100644
index 4e7d74474f9c..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/mixed/HBMEntity.hbm.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
- hbmentity_id_sequence
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/mixed/XmlEntity.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/mixed/XmlEntity.xml
new file mode 100644
index 000000000000..38d8d7b57205
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/bootstrap/binding/mixed/XmlEntity.xml
@@ -0,0 +1,25 @@
+
+
+
+
+ org.hibernate.orm.test.bootstrap.binding.mixed
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bytecode/Bean.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bytecode/Bean.hbm.xml
deleted file mode 100644
index 77291fa1fa7a..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/bytecode/Bean.hbm.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/bytecode/Bean.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/bytecode/Bean.xml
new file mode 100644
index 000000000000..b40a1d299405
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/bytecode/Bean.xml
@@ -0,0 +1,36 @@
+
+
+
+ org.hibernate.orm.test.bytecode
+
+
+
+
+
+
+
+
+
+
+
+
+ TIMESTAMP
+
+
+
+
+
+
+
+
+
+ 2004
+
+
+
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/cache/hhh13179/DiscriminatorSubclassPerson.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/cache/hhh13179/DiscriminatorSubclassPerson.hbm.xml
deleted file mode 100644
index 315c58c9ba4c..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/cache/hhh13179/DiscriminatorSubclassPerson.hbm.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/cache/hhh13179/JoinedSubclassPerson.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/cache/hhh13179/JoinedSubclassPerson.hbm.xml
deleted file mode 100644
index a6967741f3bb..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/cache/hhh13179/JoinedSubclassPerson.hbm.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/cache/hhh13179/UnionSubclassPerson.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/cache/hhh13179/UnionSubclassPerson.hbm.xml
deleted file mode 100644
index 9fa6f0ec0ef8..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/cache/hhh13179/UnionSubclassPerson.hbm.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/cfg/Cacheable.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/cfg/Cacheable.hbm.xml
deleted file mode 100644
index f674df487908..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/cfg/Cacheable.hbm.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/cfg/FooEntity.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/cfg/FooEntity.hbm.xml
deleted file mode 100644
index 7d06f0a028a3..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/cfg/FooEntity.hbm.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/cfg/FooEntity.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/cfg/FooEntity.xml
new file mode 100644
index 000000000000..eaa12c6084e2
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/cfg/FooEntity.xml
@@ -0,0 +1,19 @@
+
+
+
+ org.hibernate.orm.test.cfg
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/backref/map/compkey/Mappings.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/backref/map/compkey/Mappings.hbm.xml
deleted file mode 100644
index e733ee77eb8b..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/backref/map/compkey/Mappings.hbm.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/backref/map/compkey/Mappings.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/backref/map/compkey/Mappings.xml
new file mode 100644
index 000000000000..a738338b8beb
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/backref/map/compkey/Mappings.xml
@@ -0,0 +1,42 @@
+
+
+
+
+ org.hibernate.orm.test.collection.backref.map.compkey
+ FIELD
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/bag/Mappings.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/bag/Mappings.hbm.xml
deleted file mode 100644
index 7a92fdc743b3..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/bag/Mappings.hbm.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/bag/Mappings.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/bag/Mappings.xml
new file mode 100644
index 000000000000..f303ecb937c6
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/bag/Mappings.xml
@@ -0,0 +1,52 @@
+
+
+
+ org.hibernate.orm.test.collection.bag
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/idbag/Mappings.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/idbag/Mappings.hbm.xml
index 7317ab551449..d2eca8b20121 100644
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/idbag/Mappings.hbm.xml
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/collection/idbag/Mappings.hbm.xml
@@ -3,23 +3,29 @@
~ SPDX-License-Identifier: Apache-2.0
~ Copyright Red Hat Inc. and Hibernate Authors
-->
-
+
+ org.hibernate.orm.test.collection.idbag
+
+
+
+
+
+
+
+ Long
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/dynamicmap/Test.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/dynamicmap/Test.hbm.xml
deleted file mode 100644
index e8d2e2917f4e..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/dynamicmap/Test.hbm.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/dynamicmap/Test.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/dynamicmap/Test.xml
new file mode 100644
index 000000000000..7d83754912dc
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/dynamicmap/Test.xml
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+ true
+
+
+
+
+
+ Integer
+
+
+
+ String
+
+
+
+ String
+
+
+
+
+
+ ItemBase
+
+
+
+ int
+
+
+
+
+
+
+
+
+ ItemBase
+
+
+
+ String
+
+
+
+
+
+
+
+
+
+
+
+
+ Integer
+
+
+ String
+
+
+
+
+
+
+
+
+
+
+ Integer
+
+
+
+ String
+ -9
+
+
+
+
+
\ No newline at end of file
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/dynamicmap/artist.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/dynamicmap/artist.hbm.xml
deleted file mode 100644
index dc81cb2bd74a..000000000000
--- a/hibernate-core/src/test/resources/org/hibernate/orm/test/dynamicmap/artist.hbm.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/dynamicmap/artist.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/dynamicmap/artist.xml
new file mode 100644
index 000000000000..80a21affe773
--- /dev/null
+++ b/hibernate-core/src/test/resources/org/hibernate/orm/test/dynamicmap/artist.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+ Integer
+
+
+ String
+
+
+
+
diff --git a/whats-new.adoc b/whats-new.adoc
index 58d6c887bacf..713941a44c2b 100644
--- a/whats-new.adoc
+++ b/whats-new.adoc
@@ -285,6 +285,22 @@ New operations were added to the `Transaction` interface, allowing code to inspe
This feature is considered incubating.
====
+[[collection-id-java-class]]
+== @CollectionIdJavaClass
+
+`@CollectionIdJavaClass` is an alternative to `@CollectionIdJavaType` for simpler cases of id-bag mappings. E.g.
+
+====
+[source, java, indent=0]
+----
+@Bag
+@CollectionId(generator="increment")
+@CollectionIdJavaClass(Integer.class)
+Collection authors;
+----
+====
+
+
[[schema-manager-populate]]
== Data population