diff --git a/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java index 0eb29c9179..24c28d61e9 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/internal/InFlightMetadataCollectorImpl.java @@ -14,7 +14,6 @@ import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; -import java.util.Properties; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -457,9 +456,9 @@ public class InFlightMetadataCollectorImpl implements InFlightMetadataCollector } private CollectionTypeRegistrationDescriptor toDescriptor(CollectionTypeRegistration registrationAnnotation) { - final Properties parameters; + final Map parameters; if ( registrationAnnotation.parameters().length > 0 ) { - parameters = new Properties(); + parameters = new HashMap<>(); for ( Parameter parameter : registrationAnnotation.parameters() ) { parameters.put( parameter.name(), parameter.value() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java index c7a9b4e042..a1eaf06429 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java @@ -764,24 +764,24 @@ public class ModelBinder { String unsavedValue, SimpleValue identifierValue) { if ( generator != null ) { - String generatorName = generator.getStrategy(); - Properties params = new Properties(); + final Map params = new HashMap<>(); // see if the specified generator name matches a registered - IdentifierGeneratorDefinition generatorDef = sourceDocument.getMetadataCollector().getIdentifierGenerator( generatorName ); + String generatorName = generator.getStrategy(); + final IdentifierGeneratorDefinition generatorDef = sourceDocument.getMetadataCollector() + .getIdentifierGenerator( generatorName ); if ( generatorDef != null ) { generatorName = generatorDef.getStrategy(); params.putAll( generatorDef.getParameters() ); } - identifierValue.setIdentifierGeneratorStrategy( generatorName ); // YUCK! but cannot think of a clean way to do this given the string-config based scheme - params.put( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, objectNameNormalizer); + params.put( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, objectNameNormalizer ); params.putAll( generator.getParameters() ); - identifierValue.setIdentifierGeneratorProperties( params ); + identifierValue.setIdentifierGeneratorParameters( params ); } identifierValue.getTable().setIdentifierValue( identifierValue ); diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/InFlightMetadataCollector.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/InFlightMetadataCollector.java index c19a6c3fad..86e96b9ad2 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/spi/InFlightMetadataCollector.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/InFlightMetadataCollector.java @@ -362,9 +362,9 @@ public interface InFlightMetadataCollector extends Mapping, MetadataImplementor class CollectionTypeRegistrationDescriptor { private final Class implementation; - private final Properties parameters; + private final Map parameters; - public CollectionTypeRegistrationDescriptor(Class implementation, Properties parameters) { + public CollectionTypeRegistrationDescriptor(Class implementation, Map parameters) { this.implementation = implementation; this.parameters = parameters; } @@ -373,7 +373,7 @@ public interface InFlightMetadataCollector extends Mapping, MetadataImplementor return implementation; } - public Properties getParameters() { + public Map getParameters() { return parameters; } } diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java b/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java index 4b3482063e..86b814d236 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java @@ -17,7 +17,6 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Properties; import java.util.Set; import java.util.StringTokenizer; import java.util.function.Consumer; @@ -730,13 +729,13 @@ public class BinderHelper { //generator settings id.setIdentifierGeneratorStrategy( generatorType ); - Properties params = new Properties(); + final Map params = new HashMap<>(); //always settable - params.setProperty( PersistentIdentifierGenerator.TABLE, table.getName() ); + params.put( PersistentIdentifierGenerator.TABLE, table.getName() ); if ( id.getColumnSpan() == 1 ) { - params.setProperty( PersistentIdentifierGenerator.PK, id.getColumns().get(0).getName() ); + params.put( PersistentIdentifierGenerator.PK, id.getColumns().get(0).getName() ); } // YUCK! but cannot think of a clean way to do this given the string-config based scheme params.put( PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER, buildingContext.getObjectNameNormalizer() ); @@ -764,17 +763,16 @@ public class BinderHelper { id.setIdentifierGeneratorStrategy( identifierGeneratorStrategy ); } //checkIfMatchingGenerator(gen, generatorType, generatorName); - for ( Map.Entry elt : gen.getParameters().entrySet() ) { - if ( elt.getKey() == null ) { - continue; + for ( Map.Entry elt : gen.getParameters().entrySet() ) { + if ( elt.getKey() != null ) { + params.put( elt.getKey(), elt.getValue() ); } - params.setProperty( (String) elt.getKey(), (String) elt.getValue() ); } } if ( "assigned".equals( generatorType ) ) { id.setNullValue( "undefined" ); } - id.setIdentifierGeneratorProperties( params ); + id.setIdentifierGeneratorParameters( params ); } /** diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java index f53210a562..8c5dc5b9eb 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java @@ -233,7 +233,7 @@ public abstract class CollectionBinder { private SortComparator comparatorSort; private String explicitType; - private final Properties explicitTypeParameters = new Properties(); + private final Map explicitTypeParameters = new HashMap<>(); protected CollectionBinder( Supplier> customTypeBeanResolver, @@ -758,7 +758,7 @@ public abstract class CollectionBinder { // todo (6.0) - technically, these should no longer be needed binder.explicitType = typeAnnotation.type().getName(); for ( Parameter param : typeAnnotation.parameters() ) { - binder.explicitTypeParameters.setProperty( param.name(), param.value() ); + binder.explicitTypeParameters.put( param.name(), param.value() ); } } else { @@ -798,7 +798,7 @@ public abstract class CollectionBinder { private static ManagedBean createCustomType( String role, Class implementation, - Properties parameters, + Map parameters, MetadataBuildingContext buildingContext) { final StandardServiceRegistry serviceRegistry = buildingContext.getBuildingOptions().getServiceRegistry(); final ManagedBeanRegistry beanRegistry = serviceRegistry.getService( ManagedBeanRegistry.class ); @@ -812,7 +812,9 @@ public abstract class CollectionBinder { // a separate bean instance which means uniquely naming it final ManagedBean typeBean = beanRegistry.getBean( role, implementation ); final UserCollectionType type = typeBean.getBeanInstance(); - ( (ParameterizedType) type ).setParameterValues( parameters ); + final Properties properties = new Properties(); + properties.putAll( parameters ); + ( (ParameterizedType) type ).setParameterValues( properties ); return typeBean; } else { diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java index 054ceb636b..6bf1df87c1 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/SimpleValue.java @@ -10,6 +10,7 @@ import java.io.Serializable; import java.lang.annotation.Annotation; import java.sql.Types; import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -21,6 +22,7 @@ import jakarta.persistence.AttributeConverter; import org.hibernate.AssertionFailure; import org.hibernate.FetchMode; import org.hibernate.MappingException; +import org.hibernate.Remove; import org.hibernate.TimeZoneStorageStrategy; import org.hibernate.annotations.common.reflection.XProperty; import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor; @@ -85,7 +87,7 @@ public abstract class SimpleValue implements KeyValue { private boolean isNationalized; private boolean isLob; - private Properties identifierGeneratorProperties; + private Map identifierGeneratorParameters; private String identifierGeneratorStrategy = DEFAULT_ID_GEN_STRATEGY; private String nullValue; @@ -120,9 +122,7 @@ public abstract class SimpleValue implements KeyValue { this.isVersion = original.isVersion; this.isNationalized = original.isNationalized; this.isLob = original.isLob; - this.identifierGeneratorProperties = original.identifierGeneratorProperties == null - ? null - : new Properties( original.identifierGeneratorProperties ); + this.identifierGeneratorParameters = original.identifierGeneratorParameters; this.identifierGeneratorStrategy = original.identifierGeneratorStrategy; this.nullValue = original.nullValue; this.table = original.table; @@ -494,8 +494,8 @@ public abstract class SimpleValue implements KeyValue { params.setProperty( OptimizableGenerator.IMPLICIT_NAME_BASE, tableName ); } - if ( identifierGeneratorProperties != null ) { - params.putAll( identifierGeneratorProperties ); + if ( identifierGeneratorParameters != null ) { + params.putAll(identifierGeneratorParameters); } // TODO : we should pass along all settings once "config lifecycle" is hashed out... @@ -556,28 +556,43 @@ public abstract class SimpleValue implements KeyValue { ); } + public Map getIdentifierGeneratorParameters() { + return identifierGeneratorParameters; + } + + public void setIdentifierGeneratorParameters(Map identifierGeneratorParameters) { + this.identifierGeneratorParameters = identifierGeneratorParameters; + } + + /** + * @deprecated use {@link #getIdentifierGeneratorParameters()} + */ + @Deprecated @Remove public Properties getIdentifierGeneratorProperties() { - return identifierGeneratorProperties; + Properties properties = new Properties(); + properties.putAll( identifierGeneratorParameters ); + return properties; } /** - * Sets the identifierGeneratorProperties. - * @param identifierGeneratorProperties The identifierGeneratorProperties to set + * @deprecated use {@link #setIdentifierGeneratorParameters(Map)} */ + @Deprecated @Remove public void setIdentifierGeneratorProperties(Properties identifierGeneratorProperties) { - this.identifierGeneratorProperties = identifierGeneratorProperties; + this.identifierGeneratorParameters = new HashMap<>(); + identifierGeneratorProperties.forEach((key, value) -> { + if (key instanceof String) { + identifierGeneratorParameters.put((String) key, value); + } + }); } /** - * Sets the identifierGeneratorProperties. - * @param identifierGeneratorProperties The identifierGeneratorProperties to set + * @deprecated use {@link #setIdentifierGeneratorParameters(Map)} */ - public void setIdentifierGeneratorProperties(Map identifierGeneratorProperties) { - if ( identifierGeneratorProperties != null ) { - Properties properties = new Properties(); - properties.putAll( identifierGeneratorProperties ); - setIdentifierGeneratorProperties( properties ); - } + @Deprecated @Remove + public void setIdentifierGeneratorProperties(Map identifierGeneratorProperties) { + this.identifierGeneratorParameters = identifierGeneratorProperties; } public String getNullValue() { @@ -634,7 +649,7 @@ public abstract class SimpleValue implements KeyValue { } public boolean isNullable() { - for (Selectable selectable : getSelectables()) { + for ( Selectable selectable : getSelectables() ) { if ( selectable instanceof Formula ) { // if there are *any* formulas, then the Value overall is // considered nullable