remove some uses of java.util.Properties
This commit is contained in:
parent
239fc9a835
commit
5ea136781c
|
@ -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<String,String> parameters;
|
||||
if ( registrationAnnotation.parameters().length > 0 ) {
|
||||
parameters = new Properties();
|
||||
parameters = new HashMap<>();
|
||||
for ( Parameter parameter : registrationAnnotation.parameters() ) {
|
||||
parameters.put( parameter.name(), parameter.value() );
|
||||
}
|
||||
|
|
|
@ -764,24 +764,24 @@ public class ModelBinder {
|
|||
String unsavedValue,
|
||||
SimpleValue identifierValue) {
|
||||
if ( generator != null ) {
|
||||
String generatorName = generator.getStrategy();
|
||||
Properties params = new Properties();
|
||||
final Map<String,Object> params = new HashMap<>();
|
||||
|
||||
// see if the specified generator name matches a registered <identifier-generator/>
|
||||
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 );
|
||||
|
|
|
@ -362,9 +362,9 @@ public interface InFlightMetadataCollector extends Mapping, MetadataImplementor
|
|||
|
||||
class CollectionTypeRegistrationDescriptor {
|
||||
private final Class<? extends UserCollectionType> implementation;
|
||||
private final Properties parameters;
|
||||
private final Map<String,String> parameters;
|
||||
|
||||
public CollectionTypeRegistrationDescriptor(Class<? extends UserCollectionType> implementation, Properties parameters) {
|
||||
public CollectionTypeRegistrationDescriptor(Class<? extends UserCollectionType> implementation, Map<String,String> parameters) {
|
||||
this.implementation = implementation;
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ public interface InFlightMetadataCollector extends Mapping, MetadataImplementor
|
|||
return implementation;
|
||||
}
|
||||
|
||||
public Properties getParameters() {
|
||||
public Map<String,String> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<String,Object> 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<String,String> 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 );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -233,7 +233,7 @@ public abstract class CollectionBinder {
|
|||
private SortComparator comparatorSort;
|
||||
|
||||
private String explicitType;
|
||||
private final Properties explicitTypeParameters = new Properties();
|
||||
private final Map<String,String> explicitTypeParameters = new HashMap<>();
|
||||
|
||||
protected CollectionBinder(
|
||||
Supplier<ManagedBean<? extends UserCollectionType>> 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<? extends UserCollectionType> createCustomType(
|
||||
String role,
|
||||
Class<? extends UserCollectionType> implementation,
|
||||
Properties parameters,
|
||||
Map<String,String> 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<? extends UserCollectionType> 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 {
|
||||
|
|
|
@ -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<String,Object> 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<String, Object> getIdentifierGeneratorParameters() {
|
||||
return identifierGeneratorParameters;
|
||||
}
|
||||
|
||||
public void setIdentifierGeneratorParameters(Map<String, Object> 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<String,Object> 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
|
||||
|
|
Loading…
Reference in New Issue