HHH-17961 - Drop support for hibernate.mapping.precedence

This commit is contained in:
Steve Ebersole 2024-04-15 11:18:40 -05:00
parent 0dddeaa458
commit c475e9e746
11 changed files with 9 additions and 212 deletions

View File

@ -18,7 +18,6 @@ import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject; import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
import org.hibernate.boot.model.relational.ColumnOrderingStrategy; import org.hibernate.boot.model.relational.ColumnOrderingStrategy;
import org.hibernate.cache.spi.access.AccessType; import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.MetadataSourceType;
import org.hibernate.metamodel.CollectionClassification; import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor; import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
@ -348,27 +347,6 @@ public interface MetadataBuilder {
*/ */
MetadataBuilder applyTempClassLoader(ClassLoader tempClassLoader); MetadataBuilder applyTempClassLoader(ClassLoader tempClassLoader);
/**
* Apply a specific ordering to the processing of sources.
* <p>
* Unlike most of the methods of this interface (which deal with multiple
* values internally), this one <em>replaces</em> any source processing
* order that was already set.
* <p>
* 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} * Apply an explicit {@link FunctionContributor}
* (implicit application via {@link java.util.ServiceLoader} will still happen too) * (implicit application via {@link java.util.ServiceLoader} will still happen too)

View File

@ -60,7 +60,6 @@ import org.hibernate.boot.spi.MetadataSourcesContributor;
import org.hibernate.cache.spi.RegionFactory; import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.access.AccessType; import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.MetadataSourceType;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.TimeZoneSupport; import org.hibernate.dialect.TimeZoneSupport;
import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.engine.config.spi.ConfigurationService;
@ -345,13 +344,6 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
return this; return this;
} }
@Override
@Deprecated
public MetadataBuilder applySourceProcessOrdering(MetadataSourceType... sourceTypes) {
Collections.addAll( options.sourceProcessOrdering, sourceTypes );
return this;
}
public MetadataBuilder allowSpecjSyntax() { public MetadataBuilder allowSpecjSyntax() {
this.options.specjProprietarySyntaxEnabled = true; this.options.specjProprietarySyntaxEnabled = true;
return this; return this;
@ -612,7 +604,6 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
private boolean useNationalizedCharacterData; private boolean useNationalizedCharacterData;
private boolean specjProprietarySyntaxEnabled; private boolean specjProprietarySyntaxEnabled;
private boolean noConstraintByDefault; private boolean noConstraintByDefault;
private final ArrayList<MetadataSourceType> sourceProcessOrdering;
private final String schemaCharset; private final String schemaCharset;
private final boolean xmlMappingEnabled; private final boolean xmlMappingEnabled;
@ -757,8 +748,6 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
} }
); );
this.sourceProcessOrdering = resolveInitialSourceProcessOrdering( configService );
this.useNationalizedCharacterData = configService.getSetting( this.useNationalizedCharacterData = configService.getSetting(
AvailableSettings.USE_NATIONALIZED_CHARACTER_DATA, AvailableSettings.USE_NATIONALIZED_CHARACTER_DATA,
BOOLEAN, BOOLEAN,
@ -778,28 +767,6 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
); );
} }
private ArrayList<MetadataSourceType> resolveInitialSourceProcessOrdering(ConfigurationService configService) {
final ArrayList<MetadataSourceType> 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 @Override
public StandardServiceRegistry getServiceRegistry() { public StandardServiceRegistry getServiceRegistry() {
return serviceRegistry; return serviceRegistry;
@ -954,11 +921,6 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
return noConstraintByDefault; return noConstraintByDefault;
} }
@Override
public List<MetadataSourceType> getSourceProcessOrdering() {
return sourceProcessOrdering;
}
@Override @Override
public String getSchemaCharset() { public String getSchemaCharset() {
return schemaCharset; return schemaCharset;

View File

@ -68,7 +68,6 @@ import org.hibernate.boot.spi.MappingDefaults;
import org.hibernate.boot.spi.MetadataBuildingOptions; import org.hibernate.boot.spi.MetadataBuildingOptions;
import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.MetadataSourceType;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.config.spi.StandardConverters; import org.hibernate.engine.config.spi.StandardConverters;
@ -263,8 +262,6 @@ public class MetadataBuildingProcess {
@Override @Override
public void prepare() { public void prepare() {
hbmProcessor.prepare(); hbmProcessor.prepare();
annotationProcessor.prepare(); annotationProcessor.prepare();
} }
@ -312,41 +309,20 @@ public class MetadataBuildingProcess {
@Override @Override
public void prepareForEntityHierarchyProcessing() { public void prepareForEntityHierarchyProcessing() {
for ( MetadataSourceType metadataSourceType : options.getSourceProcessOrdering() ) { hbmProcessor.prepareForEntityHierarchyProcessing();
if ( metadataSourceType == MetadataSourceType.HBM ) { annotationProcessor.prepareForEntityHierarchyProcessing();
hbmProcessor.prepareForEntityHierarchyProcessing();
}
if ( metadataSourceType == MetadataSourceType.CLASS ) {
annotationProcessor.prepareForEntityHierarchyProcessing();
}
}
} }
@Override @Override
public void processEntityHierarchies(Set<String> processedEntityNames) { public void processEntityHierarchies(Set<String> processedEntityNames) {
for ( MetadataSourceType metadataSourceType : options.getSourceProcessOrdering() ) { hbmProcessor.processEntityHierarchies( processedEntityNames );
if ( metadataSourceType == MetadataSourceType.HBM ) { annotationProcessor.processEntityHierarchies( processedEntityNames );
hbmProcessor.processEntityHierarchies( processedEntityNames );
}
if ( metadataSourceType == MetadataSourceType.CLASS ) {
annotationProcessor.processEntityHierarchies( processedEntityNames );
}
}
} }
@Override @Override
public void postProcessEntityHierarchies() { public void postProcessEntityHierarchies() {
for ( MetadataSourceType metadataSourceType : options.getSourceProcessOrdering() ) { hbmProcessor.postProcessEntityHierarchies();
if ( metadataSourceType == MetadataSourceType.HBM ) { annotationProcessor.postProcessEntityHierarchies();
hbmProcessor.postProcessEntityHierarchies();
}
if ( metadataSourceType == MetadataSourceType.CLASS ) {
annotationProcessor.postProcessEntityHierarchies();
}
}
} }
@Override @Override

View File

@ -21,7 +21,6 @@ import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject; import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
import org.hibernate.boot.model.relational.ColumnOrderingStrategy; import org.hibernate.boot.model.relational.ColumnOrderingStrategy;
import org.hibernate.cache.spi.access.AccessType; import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.MetadataSourceType;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor; import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
import org.hibernate.usertype.UserType; import org.hibernate.usertype.UserType;
@ -190,12 +189,6 @@ public abstract class AbstractDelegatingMetadataBuilderImplementor<T extends Met
return getThis(); return getThis();
} }
@Override
public MetadataBuilder applySourceProcessOrdering(MetadataSourceType... sourceTypes) {
delegate.applySourceProcessOrdering( sourceTypes );
return getThis();
}
@Override @Override
public MetadataBuilder applyFunctions(FunctionContributor functionContributor) { public MetadataBuilder applyFunctions(FunctionContributor functionContributor) {
delegate.applyFunctions( functionContributor ); delegate.applyFunctions( functionContributor );

View File

@ -16,7 +16,6 @@ import org.hibernate.boot.model.relational.ColumnOrderingStrategy;
import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata; import org.hibernate.boot.models.xml.spi.PersistenceUnitMetadata;
import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.cache.spi.access.AccessType; import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.MetadataSourceType;
import org.hibernate.dialect.TimeZoneSupport; import org.hibernate.dialect.TimeZoneSupport;
import org.hibernate.id.factory.IdentifierGeneratorFactory; import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.type.WrapperArrayHandling; import org.hibernate.type.WrapperArrayHandling;
@ -149,11 +148,6 @@ public abstract class AbstractDelegatingMetadataBuildingOptions implements Metad
return delegate.isNoConstraintByDefault(); return delegate.isNoConstraintByDefault();
} }
@Override
public List<MetadataSourceType> getSourceProcessOrdering() {
return delegate.getSourceProcessOrdering();
}
@Override @Override
public void apply(JpaOrmXmlPersistenceUnitDefaults jpaOrmXmlPersistenceUnitDefaults) { public void apply(JpaOrmXmlPersistenceUnitDefaults jpaOrmXmlPersistenceUnitDefaults) {
if ( delegate instanceof JpaOrmXmlPersistenceUnitDefaultAware ) { if ( delegate instanceof JpaOrmXmlPersistenceUnitDefaultAware ) {

View File

@ -14,7 +14,6 @@ import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
import org.hibernate.boot.model.relational.ColumnOrderingStrategy; import org.hibernate.boot.model.relational.ColumnOrderingStrategy;
import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.cache.spi.access.AccessType; import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.MetadataSourceType;
import org.hibernate.collection.internal.StandardCollectionSemanticsResolver; import org.hibernate.collection.internal.StandardCollectionSemanticsResolver;
import org.hibernate.collection.spi.CollectionSemanticsResolver; import org.hibernate.collection.spi.CollectionSemanticsResolver;
import org.hibernate.dialect.TimeZoneSupport; import org.hibernate.dialect.TimeZoneSupport;
@ -216,15 +215,6 @@ public interface MetadataBuildingOptions {
*/ */
boolean isNoConstraintByDefault(); 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<MetadataSourceType> getSourceProcessOrdering();
/** /**
* @see org.hibernate.cfg.AvailableSettings#HBM2DDL_CHARSET_NAME * @see org.hibernate.cfg.AvailableSettings#HBM2DDL_CHARSET_NAME
*/ */

View File

@ -159,9 +159,6 @@ public class Configuration {
private ColumnOrderingStrategy columnOrderingStrategy; private ColumnOrderingStrategy columnOrderingStrategy;
private SharedCacheMode sharedCacheMode; 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} * Create a new instance, using a default {@link BootstrapServiceRegistry}
* and a newly instantiated {@link MetadataSources}. * and a newly instantiated {@link MetadataSources}.

View File

@ -421,22 +421,6 @@ public interface MappingSettings {
*/ */
String COLUMN_ORDERING_STRATEGY = "hibernate.column_ordering_strategy"; 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. * Whether XML mappings should be processed.
* *

View File

@ -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 + "]" );
}
}

View File

@ -9,6 +9,7 @@
package org.hibernate.orm.test.annotations; package org.hibernate.orm.test.annotations;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
import org.hibernate.cfg.MappingSettings;
import org.hibernate.query.Query; import org.hibernate.query.Query;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
@ -56,7 +57,7 @@ public class ConfigurationTest {
ServiceRegistryUtil.applySettings( cfg.getStandardServiceRegistryBuilder() ); ServiceRegistryUtil.applySettings( cfg.getStandardServiceRegistryBuilder() );
cfg.configure( "org/hibernate/orm/test/annotations/hibernate.cfg.xml" ); cfg.configure( "org/hibernate/orm/test/annotations/hibernate.cfg.xml" );
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" ); 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() ) { try ( SessionFactoryImplementor sf = (SessionFactoryImplementor) cfg.buildSessionFactory() ) {
assertNotNull( sf ); 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 @Test
public void testHbmWithSubclassExtends() { public void testHbmWithSubclassExtends() {
Configuration cfg = new Configuration(); Configuration cfg = new Configuration();

View File

@ -128,6 +128,7 @@ String isDefault();
* Removed `AdditionalJaxbMappingProducer`, deprecated in favor of `AdditionalMappingContributor` * Removed `AdditionalJaxbMappingProducer`, deprecated in favor of `AdditionalMappingContributor`
* Removed `MetadataContributor`, deprecated in favor of `AdditionalMappingContributor` * Removed `MetadataContributor`, deprecated in favor of `AdditionalMappingContributor`
* Removed `@Persister`. * Removed `@Persister`.
* Removed `hibernate.mapping.precedence` and friends
[[todo]] [[todo]]