From c475e9e746ed42ab4aaaaea727840f27d8cf10d0 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 15 Apr 2024 11:18:40 -0500 Subject: [PATCH] HHH-17961 - Drop support for hibernate.mapping.precedence --- .../org/hibernate/boot/MetadataBuilder.java | 22 -------- .../boot/internal/MetadataBuilderImpl.java | 38 -------------- .../process/spi/MetadataBuildingProcess.java | 36 +++---------- ...tDelegatingMetadataBuilderImplementor.java | 7 --- ...ractDelegatingMetadataBuildingOptions.java | 6 --- .../boot/spi/MetadataBuildingOptions.java | 10 ---- .../java/org/hibernate/cfg/Configuration.java | 3 -- .../org/hibernate/cfg/MappingSettings.java | 16 ------ .../org/hibernate/cfg/MetadataSourceType.java | 52 ------------------- .../test/annotations/ConfigurationTest.java | 30 +---------- migration-guide.adoc | 1 + 11 files changed, 9 insertions(+), 212 deletions(-) delete mode 100644 hibernate-core/src/main/java/org/hibernate/cfg/MetadataSourceType.java diff --git a/hibernate-core/src/main/java/org/hibernate/boot/MetadataBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/MetadataBuilder.java index c209569e3e..31537259b9 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/MetadataBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/MetadataBuilder.java @@ -18,7 +18,6 @@ import org.hibernate.boot.model.naming.PhysicalNamingStrategy; import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject; import org.hibernate.boot.model.relational.ColumnOrderingStrategy; import org.hibernate.cache.spi.access.AccessType; -import org.hibernate.cfg.MetadataSourceType; import org.hibernate.metamodel.CollectionClassification; import org.hibernate.query.sqm.function.SqmFunctionDescriptor; import org.hibernate.type.BasicType; @@ -348,27 +347,6 @@ public interface MetadataBuilder { */ MetadataBuilder applyTempClassLoader(ClassLoader tempClassLoader); - /** - * Apply a specific ordering to the processing of sources. - *

- * Unlike most of the methods of this interface (which deal with multiple - * values internally), this one replaces any source processing - * order that was already set. - *

- * Its default is defined by the {@value org.hibernate.cfg.AvailableSettings#ARTIFACT_PROCESSING_ORDER} - * setting if using property-based configuration. - * - * @param sourceTypes The types, in the order they should be processed - * - * @return {@code this} for method chaining - * - * @see org.hibernate.cfg.AvailableSettings#ARTIFACT_PROCESSING_ORDER - * - * @deprecated {@code hbm.xml} mappings are no longer supported, making this irrelevant - */ - @Deprecated(since = "6", forRemoval = true) - MetadataBuilder applySourceProcessOrdering(MetadataSourceType... sourceTypes); - /** * Apply an explicit {@link FunctionContributor} * (implicit application via {@link java.util.ServiceLoader} will still happen too) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java index 16f516da74..2809768246 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/MetadataBuilderImpl.java @@ -60,7 +60,6 @@ import org.hibernate.boot.spi.MetadataSourcesContributor; import org.hibernate.cache.spi.RegionFactory; import org.hibernate.cache.spi.access.AccessType; import org.hibernate.cfg.AvailableSettings; -import org.hibernate.cfg.MetadataSourceType; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.TimeZoneSupport; import org.hibernate.engine.config.spi.ConfigurationService; @@ -345,13 +344,6 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont return this; } - @Override - @Deprecated - public MetadataBuilder applySourceProcessOrdering(MetadataSourceType... sourceTypes) { - Collections.addAll( options.sourceProcessOrdering, sourceTypes ); - return this; - } - public MetadataBuilder allowSpecjSyntax() { this.options.specjProprietarySyntaxEnabled = true; return this; @@ -612,7 +604,6 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont private boolean useNationalizedCharacterData; private boolean specjProprietarySyntaxEnabled; private boolean noConstraintByDefault; - private final ArrayList sourceProcessOrdering; private final String schemaCharset; private final boolean xmlMappingEnabled; @@ -757,8 +748,6 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont } ); - this.sourceProcessOrdering = resolveInitialSourceProcessOrdering( configService ); - this.useNationalizedCharacterData = configService.getSetting( AvailableSettings.USE_NATIONALIZED_CHARACTER_DATA, BOOLEAN, @@ -778,28 +767,6 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont ); } - private ArrayList resolveInitialSourceProcessOrdering(ConfigurationService configService) { - final ArrayList initialSelections = new ArrayList<>(); - - final String sourceProcessOrderingSetting = configService.getSetting( - AvailableSettings.ARTIFACT_PROCESSING_ORDER, - StandardConverters.STRING - ); - if ( sourceProcessOrderingSetting != null ) { - final String[] orderChoices = StringHelper.split( ",; ", sourceProcessOrderingSetting, false ); - initialSelections.addAll( CollectionHelper.arrayList( orderChoices.length ) ); - for ( String orderChoice : orderChoices ) { - initialSelections.add( MetadataSourceType.parsePrecedence( orderChoice ) ); - } - } - if ( initialSelections.isEmpty() ) { - initialSelections.add( MetadataSourceType.HBM ); - initialSelections.add( MetadataSourceType.CLASS ); - } - - return initialSelections; - } - @Override public StandardServiceRegistry getServiceRegistry() { return serviceRegistry; @@ -954,11 +921,6 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont return noConstraintByDefault; } - @Override - public List getSourceProcessOrdering() { - return sourceProcessOrdering; - } - @Override public String getSchemaCharset() { return schemaCharset; 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 ad48ead06a..a8f8fe74aa 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 @@ -68,7 +68,6 @@ import org.hibernate.boot.spi.MappingDefaults; import org.hibernate.boot.spi.MetadataBuildingOptions; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.cfg.AvailableSettings; -import org.hibernate.cfg.MetadataSourceType; import org.hibernate.dialect.Dialect; import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.engine.config.spi.StandardConverters; @@ -263,8 +262,6 @@ public class MetadataBuildingProcess { @Override public void prepare() { hbmProcessor.prepare(); - - annotationProcessor.prepare(); } @@ -312,41 +309,20 @@ public class MetadataBuildingProcess { @Override public void prepareForEntityHierarchyProcessing() { - for ( MetadataSourceType metadataSourceType : options.getSourceProcessOrdering() ) { - if ( metadataSourceType == MetadataSourceType.HBM ) { - hbmProcessor.prepareForEntityHierarchyProcessing(); - } - - if ( metadataSourceType == MetadataSourceType.CLASS ) { - annotationProcessor.prepareForEntityHierarchyProcessing(); - } - } + hbmProcessor.prepareForEntityHierarchyProcessing(); + annotationProcessor.prepareForEntityHierarchyProcessing(); } @Override public void processEntityHierarchies(Set processedEntityNames) { - for ( MetadataSourceType metadataSourceType : options.getSourceProcessOrdering() ) { - if ( metadataSourceType == MetadataSourceType.HBM ) { - hbmProcessor.processEntityHierarchies( processedEntityNames ); - } - - if ( metadataSourceType == MetadataSourceType.CLASS ) { - annotationProcessor.processEntityHierarchies( processedEntityNames ); - } - } + hbmProcessor.processEntityHierarchies( processedEntityNames ); + annotationProcessor.processEntityHierarchies( processedEntityNames ); } @Override public void postProcessEntityHierarchies() { - for ( MetadataSourceType metadataSourceType : options.getSourceProcessOrdering() ) { - if ( metadataSourceType == MetadataSourceType.HBM ) { - hbmProcessor.postProcessEntityHierarchies(); - } - - if ( metadataSourceType == MetadataSourceType.CLASS ) { - annotationProcessor.postProcessEntityHierarchies(); - } - } + hbmProcessor.postProcessEntityHierarchies(); + annotationProcessor.postProcessEntityHierarchies(); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadataBuilderImplementor.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadataBuilderImplementor.java index 77aa600575..0598531510 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadataBuilderImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadataBuilderImplementor.java @@ -21,7 +21,6 @@ import org.hibernate.boot.model.naming.PhysicalNamingStrategy; import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject; import org.hibernate.boot.model.relational.ColumnOrderingStrategy; import org.hibernate.cache.spi.access.AccessType; -import org.hibernate.cfg.MetadataSourceType; import org.hibernate.query.sqm.function.SqmFunctionDescriptor; import org.hibernate.type.BasicType; import org.hibernate.usertype.UserType; @@ -190,12 +189,6 @@ public abstract class AbstractDelegatingMetadataBuilderImplementor getSourceProcessOrdering() { - return delegate.getSourceProcessOrdering(); - } - @Override public void apply(JpaOrmXmlPersistenceUnitDefaults jpaOrmXmlPersistenceUnitDefaults) { if ( delegate instanceof JpaOrmXmlPersistenceUnitDefaultAware ) { diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataBuildingOptions.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataBuildingOptions.java index d75810db55..374e099c41 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataBuildingOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/MetadataBuildingOptions.java @@ -14,7 +14,6 @@ import org.hibernate.boot.model.naming.PhysicalNamingStrategy; import org.hibernate.boot.model.relational.ColumnOrderingStrategy; import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.cache.spi.access.AccessType; -import org.hibernate.cfg.MetadataSourceType; import org.hibernate.collection.internal.StandardCollectionSemanticsResolver; import org.hibernate.collection.spi.CollectionSemanticsResolver; import org.hibernate.dialect.TimeZoneSupport; @@ -216,15 +215,6 @@ public interface MetadataBuildingOptions { */ boolean isNoConstraintByDefault(); - /** - * Retrieve the ordering in which {@linkplain MetadataSourceType sources} should be processed. - * - * @return The order in which sources should be processed. - * - * @see org.hibernate.cfg.AvailableSettings#ARTIFACT_PROCESSING_ORDER - */ - List getSourceProcessOrdering(); - /** * @see org.hibernate.cfg.AvailableSettings#HBM2DDL_CHARSET_NAME */ diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java index d28500ca85..461bcbe241 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java @@ -159,9 +159,6 @@ public class Configuration { private ColumnOrderingStrategy columnOrderingStrategy; private SharedCacheMode sharedCacheMode; - @Deprecated(since = "6", forRemoval = true) - public static final String ARTEFACT_PROCESSING_ORDER = AvailableSettings.ARTIFACT_PROCESSING_ORDER; - /** * Create a new instance, using a default {@link BootstrapServiceRegistry} * and a newly instantiated {@link MetadataSources}. diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/MappingSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/MappingSettings.java index 9efcd840dc..3ea3a05f6b 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/MappingSettings.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/MappingSettings.java @@ -421,22 +421,6 @@ public interface MappingSettings { */ String COLUMN_ORDERING_STRATEGY = "hibernate.column_ordering_strategy"; - /** - * Specifies the order in which metadata sources should be processed, is a delimited list - * of values defined by {@link MetadataSourceType}. - * - * @settingDefault {@code "hbm,class"}, which indicates that {@code hbm.xml} files - * should be processed first, followed by annotations and {@code orm.xml} files. - * - * @see MetadataSourceType - * @see org.hibernate.boot.MetadataBuilder#applySourceProcessOrdering(MetadataSourceType...) - * - * @deprecated {@code hbm.xml} mappings are no longer supported, making this attribute irrelevant - */ - @SuppressWarnings("DeprecatedIsStillUsed") - @Deprecated(since = "6", forRemoval = true) - String ARTIFACT_PROCESSING_ORDER = "hibernate.mapping.precedence"; - /** * Whether XML mappings should be processed. * diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/MetadataSourceType.java b/hibernate-core/src/main/java/org/hibernate/cfg/MetadataSourceType.java deleted file mode 100644 index 5a4bee5f75..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/cfg/MetadataSourceType.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html. - */ -package org.hibernate.cfg; - -import org.hibernate.HibernateException; - -/** - * Enumeration of the types of sources of mapping metadata - * - * @author Hardy Ferentschik - * @author Steve Ebersole - * - * @deprecated {@code hbm.xml} mappings are no longer supported, making this attribute irrelevant - */ -@Deprecated(since = "6", forRemoval = true) -public enum MetadataSourceType { - /** - * Indicates metadata coming from {@code hbm.xml} files - */ - HBM( "hbm" ), - /** - * Indicates metadata coming from either annotations, {@code orx.xml} or a combination of the two. - */ - CLASS( "class" ); - - private final String name; - - MetadataSourceType(String name) { - this.name = name; - } - - @Override - public String toString() { - return name; - } - - public static MetadataSourceType parsePrecedence(String value) { - if ( HBM.name.equalsIgnoreCase( value ) ) { - return HBM; - } - - if ( CLASS.name.equalsIgnoreCase( value ) ) { - return CLASS; - } - - throw new HibernateException( "Unknown metadata source type value [" + value + "]" ); - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/ConfigurationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/ConfigurationTest.java index fab30bffd0..c901d4ca26 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/ConfigurationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/ConfigurationTest.java @@ -9,6 +9,7 @@ package org.hibernate.orm.test.annotations; import org.hibernate.SessionFactory; +import org.hibernate.cfg.MappingSettings; import org.hibernate.query.Query; import org.hibernate.Session; import org.hibernate.Transaction; @@ -56,7 +57,7 @@ public class ConfigurationTest { ServiceRegistryUtil.applySettings( cfg.getStandardServiceRegistryBuilder() ); cfg.configure( "org/hibernate/orm/test/annotations/hibernate.cfg.xml" ); cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); - cfg.setProperty( Configuration.ARTEFACT_PROCESSING_ORDER, "class" ); + cfg.setProperty( MappingSettings.XML_MAPPING_ENABLED, false ); try ( SessionFactoryImplementor sf = (SessionFactoryImplementor) cfg.buildSessionFactory() ) { assertNotNull( sf ); @@ -115,33 +116,6 @@ public class ConfigurationTest { } } - @Test - public void testPrecedenceAnnotation() { - Configuration cfg = new Configuration(); - ServiceRegistryUtil.applySettings( cfg.getStandardServiceRegistryBuilder() ); - cfg.configure( "org/hibernate/orm/test/annotations/hibernate.cfg.xml" ); - cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); - cfg.setProperty( Configuration.ARTEFACT_PROCESSING_ORDER, "class, hbm" ); - cfg.addAnnotatedClass( Boat.class ); - try (SessionFactory sf = cfg.buildSessionFactory()) { - assertNotNull( sf ); - Session s = sf.openSession(); - s.getTransaction().begin(); - Boat boat = new Boat(); - boat.setSize( 12 ); - boat.setWeight( 34 ); - s.persist( boat ); - s.getTransaction().commit(); - s.clear(); - Transaction tx = s.beginTransaction(); - boat = (Boat) s.get( Boat.class, boat.getId() ); - assertTrue( 34 == boat.getWeight(), "Annotation has precedence" ); - s.delete( boat ); - tx.commit(); - s.close(); - } - } - @Test public void testHbmWithSubclassExtends() { Configuration cfg = new Configuration(); diff --git a/migration-guide.adoc b/migration-guide.adoc index fb2591f7b1..7f54c64e6a 100644 --- a/migration-guide.adoc +++ b/migration-guide.adoc @@ -128,6 +128,7 @@ String isDefault(); * Removed `AdditionalJaxbMappingProducer`, deprecated in favor of `AdditionalMappingContributor` * Removed `MetadataContributor`, deprecated in favor of `AdditionalMappingContributor` * Removed `@Persister`. +* Removed `hibernate.mapping.precedence` and friends [[todo]]