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/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/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/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..b2e57fd81279 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,
@@ -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..0abfa0153eca 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;
@@ -1001,6 +1012,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 +1062,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/spi/XmlDocumentContext.java b/hibernate-core/src/main/java/org/hibernate/boot/models/xml/spi/XmlDocumentContext.java
index c0680ec8d5cd..812e55af77e6 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,13 @@
*/
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.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,130 +49,6 @@ 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) {
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/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/Address.java b/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/entityname/Address.java
deleted file mode 100644
index f75636ff93a4..000000000000
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/boot/models/hbm/entityname/Address.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.entityname;
-
-/**
- * @author Steve Ebersole
- */
-public class Address {
- private Integer id;
- private String txt;
-}
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/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/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/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/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
+
+
+
+