HHH-14497 - Drop legacy id-generator settings;

HHH-14718 - Drop deprecated generator implementations;
HHH-14959 - Drop IdentifierGeneratorFactory as a Service;
HHH-14960 - Add @GeneratorType for better custom generator config;
HHH-14496 - Deprecate (or drop) IdGeneratorStrategyInterpreter;
HHH-14961 - Deprecate (or drop) IdentifierGeneratorStrategyProvider;
HHH-14962 - Delay actual creation of IdentifierGenerator instances as late as possible

Add `GenerationTypeStrategy` and `GenerationTypeStrategyRegistration`;
deprecate org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider
This commit is contained in:
Steve Ebersole 2021-12-08 14:33:30 -06:00
parent 3c97ac2077
commit 848c9f0914
17 changed files with 417 additions and 90 deletions

View File

@ -14,8 +14,10 @@ import jakarta.persistence.TableGenerator;
/** /**
* Strategy for interpreting identifier generator related information. * Strategy for interpreting identifier generator related information.
* *
* @author Steve Ebersole * @deprecated (as of 6.0) see {@link org.hibernate.id.factory.spi.GenerationTypeStrategy}
* and {@link org.hibernate.id.factory.spi.GenerationTypeStrategyRegistration}
*/ */
@Deprecated
public interface IdGeneratorStrategyInterpreter { public interface IdGeneratorStrategyInterpreter {
interface GeneratorNameDeterminationContext { interface GeneratorNameDeterminationContext {
/** /**

View File

@ -15,6 +15,7 @@ import org.hibernate.boot.registry.classloading.internal.TcclLookupPrecedence;
import org.hibernate.boot.spi.SessionFactoryOptions; import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cache.spi.TimestampsCacheFactory; import org.hibernate.cache.spi.TimestampsCacheFactory;
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver; import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
import org.hibernate.id.factory.spi.GenerationTypeStrategy;
import org.hibernate.jpa.spi.JpaCompliance; import org.hibernate.jpa.spi.JpaCompliance;
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode; import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
import org.hibernate.query.hql.HqlTranslator; import org.hibernate.query.hql.HqlTranslator;
@ -2589,7 +2590,11 @@ public interface AvailableSettings {
/** /**
* IdentifierGeneratorStrategyProvider class name, the class must have a no-arg constructor * IdentifierGeneratorStrategyProvider class name, the class must have a no-arg constructor
*
* @deprecated (as of 6.0) use {@link org.hibernate.id.factory.spi.GenerationTypeStrategyRegistration}
* instead
*/ */
@Deprecated
String IDENTIFIER_GENERATOR_STRATEGY_PROVIDER = "hibernate.identifier_generator_strategy_provider"; String IDENTIFIER_GENERATOR_STRATEGY_PROVIDER = "hibernate.identifier_generator_strategy_provider";
/** /**

View File

@ -20,7 +20,10 @@ import org.hibernate.internal.CoreMessageLogger;
* Generates <tt>string</tt> values using the SQL Server NEWID() function. * Generates <tt>string</tt> values using the SQL Server NEWID() function.
* *
* @author Joseph Fifield * @author Joseph Fifield
*
* @deprecated (as of 6.0)
*/ */
@Deprecated
public class GUIDGenerator implements StandardGenerator { public class GUIDGenerator implements StandardGenerator {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( GUIDGenerator.class ); private static final CoreMessageLogger LOG = CoreLogging.messageLogger( GUIDGenerator.class );

View File

@ -11,9 +11,9 @@ import org.jboss.logging.Logger;
/** /**
* Logging related to IdentifierGeneratorFactory * Logging related to IdentifierGeneratorFactory
*/ */
public class IdGenCreationLogging { public class IdGenFactoryLogging {
public static final Logger ID_GEN_LOGGER = Logger.getLogger( "org.hibernate.orm.idgen.factory" ); public static final Logger ID_GEN_FAC_LOGGER = Logger.getLogger( "org.hibernate.orm.idgen.factory" );
public static final boolean IS_TRACE_ENABLE = ID_GEN_LOGGER.isTraceEnabled(); public static final boolean IS_TRACE_ENABLE = ID_GEN_FAC_LOGGER.isTraceEnabled();
public static final boolean IS_DEBUG_ENABLE = ID_GEN_LOGGER.isDebugEnabled(); public static final boolean IS_DEBUG_ENABLE = ID_GEN_FAC_LOGGER.isDebugEnabled();
} }

View File

@ -10,7 +10,11 @@ import java.util.Properties;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.factory.spi.GeneratorDefinitionResolver;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.type.descriptor.java.JavaType;
import jakarta.persistence.GenerationType;
/** /**
* Contract for a <tt>factory</tt> of {@link IdentifierGenerator} instances. * Contract for a <tt>factory</tt> of {@link IdentifierGenerator} instances.
@ -25,6 +29,17 @@ public interface IdentifierGeneratorFactory {
*/ */
Dialect getDialect(); Dialect getDialect();
/**
* Create an IdentifierGenerator based on the given details
*/
IdentifierGenerator createIdentifierGenerator(
GenerationType generationType,
String generatedValueGeneratorName,
String generatorName,
JavaType<?> javaTypeDescriptor,
Properties config,
GeneratorDefinitionResolver definitionResolver);
/** /**
* Given a strategy, retrieve the appropriate identifier generator instance. * Given a strategy, retrieve the appropriate identifier generator instance.
* *
@ -33,7 +48,11 @@ public interface IdentifierGeneratorFactory {
* @param config Any configuration properties given in the generator mapping. * @param config Any configuration properties given in the generator mapping.
* *
* @return The appropriate generator instance. * @return The appropriate generator instance.
*
* @deprecated (since 6.0) use {@link #createIdentifierGenerator(GenerationType, String, String, JavaType, Properties, GeneratorDefinitionResolver)}
* instead
*/ */
@Deprecated
IdentifierGenerator createIdentifierGenerator(String strategy, Type type, Properties config); IdentifierGenerator createIdentifierGenerator(String strategy, Type type, Properties config);
/** /**
@ -41,6 +60,10 @@ public interface IdentifierGeneratorFactory {
* *
* @param strategy The strategy * @param strategy The strategy
* @return The generator class. * @return The generator class.
*
* @deprecated (since 6.0) with no replacement. See
* {@link #createIdentifierGenerator(GenerationType, String, String, JavaType, Properties, GeneratorDefinitionResolver)}
*/ */
@Deprecated
Class getIdentifierGeneratorClass(String strategy); Class getIdentifierGeneratorClass(String strategy);
} }

View File

@ -0,0 +1,38 @@
/*
* 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.id.factory.internal;
import java.util.Properties;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.factory.spi.GenerationTypeStrategy;
import org.hibernate.id.factory.spi.GeneratorDefinitionResolver;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.descriptor.java.JavaType;
import jakarta.persistence.GenerationType;
public class AutoGenerationTypeStrategy implements GenerationTypeStrategy {
/**
* Singleton access
*/
public static final AutoGenerationTypeStrategy INSTANCE = new AutoGenerationTypeStrategy();
@Override
public IdentifierGenerator createIdentifierGenerator(
GenerationType generationType,
String generatorName,
JavaType<?> javaTypeDescriptor,
Properties config,
GeneratorDefinitionResolver definitionResolver,
ServiceRegistry serviceRegistry) {
assert generationType == null || generationType == GenerationType.AUTO;
throw new NotYetImplementedFor6Exception( getClass() );
}
}

View File

@ -0,0 +1,36 @@
/*
* 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.id.factory.internal;
import java.util.Properties;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.factory.spi.GenerationTypeStrategy;
import org.hibernate.id.factory.spi.GeneratorDefinitionResolver;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.descriptor.java.JavaType;
import jakarta.persistence.GenerationType;
public class IdentityGenerationTypeStrategy implements GenerationTypeStrategy {
/**
* Singleton access
*/
public static final IdentityGenerationTypeStrategy INSTANCE = new IdentityGenerationTypeStrategy();
@Override
public IdentifierGenerator createIdentifierGenerator(
GenerationType generationType,
String generatorName,
JavaType<?> javaTypeDescriptor,
Properties config,
GeneratorDefinitionResolver definitionResolver,
ServiceRegistry serviceRegistry) {
throw new NotYetImplementedFor6Exception( getClass() );
}
}

View File

@ -0,0 +1,36 @@
/*
* 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.id.factory.internal;
import java.util.Properties;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.factory.spi.GenerationTypeStrategy;
import org.hibernate.id.factory.spi.GeneratorDefinitionResolver;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.descriptor.java.JavaType;
import jakarta.persistence.GenerationType;
public class SequenceGenerationTypeStrategy implements GenerationTypeStrategy {
/**
* Singleton access
*/
public static final SequenceGenerationTypeStrategy INSTANCE = new SequenceGenerationTypeStrategy();
@Override
public IdentifierGenerator createIdentifierGenerator(
GenerationType generationType,
String generatorName,
JavaType<?> javaTypeDescriptor,
Properties config,
GeneratorDefinitionResolver definitionResolver,
ServiceRegistry serviceRegistry) {
throw new NotYetImplementedFor6Exception( getClass() );
}
}

View File

@ -7,11 +7,13 @@
package org.hibernate.id.factory.internal; package org.hibernate.id.factory.internal;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.boot.registry.selector.spi.StrategySelector; import org.hibernate.boot.registry.selector.spi.StrategySelector;
@ -31,8 +33,13 @@ import org.hibernate.id.UUIDGenerator;
import org.hibernate.id.UUIDHexGenerator; import org.hibernate.id.UUIDHexGenerator;
import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.id.enhanced.TableGenerator; import org.hibernate.id.enhanced.TableGenerator;
import org.hibernate.id.factory.IdGenFactoryLogging;
import org.hibernate.id.factory.IdentifierGeneratorFactory; import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.id.factory.spi.GenerationTypeStrategy;
import org.hibernate.id.factory.spi.GenerationTypeStrategyRegistration;
import org.hibernate.id.factory.spi.GeneratorDefinitionResolver;
import org.hibernate.id.factory.spi.StandardGenerator; import org.hibernate.id.factory.spi.StandardGenerator;
import org.hibernate.internal.log.DeprecationLogger;
import org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider; import org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider;
import org.hibernate.resource.beans.container.spi.BeanContainer; import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.ContainedBean; import org.hibernate.resource.beans.container.spi.ContainedBean;
@ -41,8 +48,11 @@ import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry; import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.hibernate.type.descriptor.java.JavaType;
import static org.hibernate.id.factory.IdGenCreationLogging.ID_GEN_LOGGER; import jakarta.persistence.GenerationType;
import static org.hibernate.id.factory.IdGenFactoryLogging.ID_GEN_FAC_LOGGER;
/** /**
* Basic <tt>templated</tt> support for {@link org.hibernate.id.factory.IdentifierGeneratorFactory} implementations. * Basic <tt>templated</tt> support for {@link org.hibernate.id.factory.IdentifierGeneratorFactory} implementations.
@ -53,6 +63,7 @@ import static org.hibernate.id.factory.IdGenCreationLogging.ID_GEN_LOGGER;
public class StandardIdentifierGeneratorFactory public class StandardIdentifierGeneratorFactory
implements IdentifierGeneratorFactory, BeanContainer.LifecycleOptions, Serializable { implements IdentifierGeneratorFactory, BeanContainer.LifecycleOptions, Serializable {
private final ConcurrentHashMap<GenerationType, GenerationTypeStrategy> generatorTypeStrategyMap = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, Class<? extends IdentifierGenerator>> legacyGeneratorClassNameMap = new ConcurrentHashMap<>(); private final ConcurrentHashMap<String, Class<? extends IdentifierGenerator>> legacyGeneratorClassNameMap = new ConcurrentHashMap<>();
private final ServiceRegistry serviceRegistry; private final ServiceRegistry serviceRegistry;
@ -91,18 +102,44 @@ public class StandardIdentifierGeneratorFactory
this.serviceRegistry = serviceRegistry; this.serviceRegistry = serviceRegistry;
if ( ignoreBeanContainer ) { if ( ignoreBeanContainer ) {
ID_GEN_LOGGER.debug( "Ignoring CDI for resolving IdentifierGenerator instances as extended or delayed CDI support was enabled" ); ID_GEN_FAC_LOGGER.debug( "Ignoring CDI for resolving IdentifierGenerator instances as extended or delayed CDI support was enabled" );
this.beanContainer = null; this.beanContainer = null;
} }
else { else {
this.beanContainer = serviceRegistry.getService( ManagedBeanRegistry.class ).getBeanContainer(); this.beanContainer = serviceRegistry.getService( ManagedBeanRegistry.class ).getBeanContainer();
if ( beanContainer == null ) { if ( beanContainer == null ) {
ID_GEN_LOGGER.debug( "Resolving IdentifierGenerator instances will not use CDI as it was not configured" ); ID_GEN_FAC_LOGGER.debug( "Resolving IdentifierGenerator instances will not use CDI as it was not configured" );
} }
} }
generatorTypeStrategyMap.put( GenerationType.AUTO, AutoGenerationTypeStrategy.INSTANCE );
generatorTypeStrategyMap.put( GenerationType.SEQUENCE, SequenceGenerationTypeStrategy.INSTANCE );
generatorTypeStrategyMap.put( GenerationType.TABLE, TableGenerationTypeStrategy.INSTANCE );
generatorTypeStrategyMap.put( GenerationType.IDENTITY, IdentityGenerationTypeStrategy.INSTANCE );
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
final Collection<GenerationTypeStrategyRegistration> generationTypeStrategyRegistrations = classLoaderService.loadJavaServices( GenerationTypeStrategyRegistration.class );
generationTypeStrategyRegistrations.forEach( (registration) -> registration.registerStrategies(
(generationType, generationTypeStrategy) -> {
final GenerationTypeStrategy previous = generatorTypeStrategyMap.put(
generationType,
generationTypeStrategy
);
if ( previous != null ) {
IdGenFactoryLogging.ID_GEN_FAC_LOGGER.debugf(
"GenerationTypeStrategyRegistration [%s] overrode previous registration for GenerationType#%s : %s",
registration,
generationType.name(),
previous
);
}
},
serviceRegistry
) );
register( "uuid2", UUIDGenerator.class ); register( "uuid2", UUIDGenerator.class );
register( "guid", GUIDGenerator.class ); // can be done with UUIDGenerator + strategy // can be done with UuidGenerator + strategy
register( "guid", GUIDGenerator.class );
register( "uuid", UUIDHexGenerator.class ); // "deprecated" for new use register( "uuid", UUIDHexGenerator.class ); // "deprecated" for new use
register( "uuid.hex", UUIDHexGenerator.class ); // uuid.hex is deprecated register( "uuid.hex", UUIDHexGenerator.class ); // uuid.hex is deprecated
register( "assigned", Assigned.class ); register( "assigned", Assigned.class );
@ -117,6 +154,10 @@ public class StandardIdentifierGeneratorFactory
final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class ); final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );
final Object providerSetting = configService.getSettings().get( AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER ); final Object providerSetting = configService.getSettings().get( AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER );
if ( providerSetting != null ) { if ( providerSetting != null ) {
DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting2(
AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER,
"supply a org.hibernate.id.factory.spi.GenerationTypeStrategyRegistration Java service"
);
final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider = serviceRegistry.getService( StrategySelector.class ).resolveStrategy( final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider = serviceRegistry.getService( StrategySelector.class ).resolveStrategy(
IdentifierGeneratorStrategyProvider.class, IdentifierGeneratorStrategyProvider.class,
providerSetting providerSetting
@ -128,13 +169,35 @@ public class StandardIdentifierGeneratorFactory
} }
private void register(String strategy, Class<? extends IdentifierGenerator> generatorClass) { private void register(String strategy, Class<? extends IdentifierGenerator> generatorClass) {
ID_GEN_LOGGER.debugf( "Registering IdentifierGenerator strategy [%s] -> [%s]", strategy, generatorClass.getName() ); ID_GEN_FAC_LOGGER.debugf( "Registering IdentifierGenerator strategy [%s] -> [%s]", strategy, generatorClass.getName() );
final Class previous = legacyGeneratorClassNameMap.put( strategy, generatorClass ); final Class previous = legacyGeneratorClassNameMap.put( strategy, generatorClass );
if ( previous != null && ID_GEN_LOGGER.isDebugEnabled() ) { if ( previous != null && ID_GEN_FAC_LOGGER.isDebugEnabled() ) {
ID_GEN_LOGGER.debugf( " - overriding [%s]", previous.getName() ); ID_GEN_FAC_LOGGER.debugf( " - overriding [%s]", previous.getName() );
} }
} }
@Override
public IdentifierGenerator createIdentifierGenerator(
GenerationType generationType,
String generatedValueGeneratorName,
String generatorName,
JavaType<?> javaTypeDescriptor,
Properties config,
GeneratorDefinitionResolver definitionResolver) {
final GenerationTypeStrategy strategy = generatorTypeStrategyMap.get( generationType );
if ( strategy != null ) {
return strategy.createIdentifierGenerator(
generationType,
generatorName,
javaTypeDescriptor,
config,
definitionResolver,
serviceRegistry
);
}
throw new NotYetImplementedFor6Exception( getClass() );
}
@Override @Override
public Dialect getDialect() { public Dialect getDialect() {
if ( dialect == null ) { if ( dialect == null ) {

View File

@ -0,0 +1,36 @@
/*
* 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.id.factory.internal;
import java.util.Properties;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.factory.spi.GenerationTypeStrategy;
import org.hibernate.id.factory.spi.GeneratorDefinitionResolver;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.descriptor.java.JavaType;
import jakarta.persistence.GenerationType;
public class TableGenerationTypeStrategy implements GenerationTypeStrategy {
/**
* Singleton access
*/
public static final TableGenerationTypeStrategy INSTANCE = new TableGenerationTypeStrategy();
@Override
public IdentifierGenerator createIdentifierGenerator(
GenerationType generationType,
String generatorName,
JavaType<?> javaTypeDescriptor,
Properties config,
GeneratorDefinitionResolver definitionResolver,
ServiceRegistry serviceRegistry) {
throw new NotYetImplementedFor6Exception( getClass() );
}
}

View File

@ -0,0 +1,30 @@
/*
* 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.id.factory.spi;
import java.util.Properties;
import jakarta.persistence.GenerationType;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.descriptor.java.JavaType;
/**
* Delegate for defining how to handle the various types of
* {@link GenerationType} possibilities.
*
* @apiNote no GenerationType indicates `hbm.xml` mapping
*/
public interface GenerationTypeStrategy {
IdentifierGenerator createIdentifierGenerator(
GenerationType generationType,
String generatorName,
JavaType<?> javaTypeDescriptor,
Properties config,
GeneratorDefinitionResolver definitionResolver,
ServiceRegistry serviceRegistry);
}

View File

@ -0,0 +1,19 @@
/*
* 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.id.factory.spi;
import java.util.function.BiConsumer;
import jakarta.persistence.GenerationType;
import org.hibernate.service.ServiceRegistry;
/**
* {@link java.util.ServiceLoader} contract for registering GenerationTypeStrategy impls
*/
public interface GenerationTypeStrategyRegistration {
void registerStrategies(BiConsumer<GenerationType, GenerationTypeStrategy> registry, ServiceRegistry serviceRegistry);
}

View File

@ -0,0 +1,19 @@
/*
* 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.id.factory.spi;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
import jakarta.persistence.GenerationType;
/**
* Access to resolve IdentifierGeneratorDefinition instances
*/
@FunctionalInterface
public interface GeneratorDefinitionResolver {
IdentifierGeneratorDefinition resolveGeneratorDefinition(GenerationType generationType, String generatorName);
}

View File

@ -177,9 +177,9 @@ public interface CoreMessageLogger extends BasicLogger {
@Message(value = "Defining %s=true ignored in HEM", id = 59) @Message(value = "Defining %s=true ignored in HEM", id = 59)
void definingFlushBeforeCompletionIgnoredInHem(String flushBeforeCompletion); void definingFlushBeforeCompletionIgnoredInHem(String flushBeforeCompletion);
@LogMessage(level = WARN) // @LogMessage(level = WARN)
@Message(value = "@ForceDiscriminator is deprecated use @DiscriminatorOptions instead.", id = 62) // @Message(value = "@ForceDiscriminator is deprecated use @DiscriminatorOptions instead.", id = 62)
void deprecatedForceDescriminatorAnnotation(); // void deprecatedForceDescriminatorAnnotation();
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "DEPRECATED : use [%s] instead with custom [%s] implementation", id = 65) @Message(value = "DEPRECATED : use [%s] instead with custom [%s] implementation", id = 65)

View File

@ -42,16 +42,16 @@ public interface DeprecationLogger extends BasicLogger {
) )
public void logDeprecatedScannerSetting(); public void logDeprecatedScannerSetting();
/** // /**
* Log message indicating the use of features that were only useful for DOM4J EntityMode, // * Log message indicating the use of features that were only useful for DOM4J EntityMode,
* which was removed a long time ago. // * which was removed a long time ago.
*/ // */
@LogMessage( level = WARN ) // @LogMessage( level = WARN )
@Message( // @Message(
value = "Use of DOM4J entity-mode is considered deprecated", // value = "Use of DOM4J entity-mode is considered deprecated",
id = 90000003 // id = 90000003
) // )
public void logDeprecationOfDomEntityModeSupport(); // public void logDeprecationOfDomEntityModeSupport();
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message( @Message(
@ -69,21 +69,21 @@ public interface DeprecationLogger extends BasicLogger {
) )
public void logDeprecationOfNonNamedIdAttribute(String entityName); public void logDeprecationOfNonNamedIdAttribute(String entityName);
/** // /**
* Log a warning about an attempt to specify no-longer-supported NamingStrategy // * Log a warning about an attempt to specify no-longer-supported NamingStrategy
* // *
* @param setting - The old setting that indicates the NamingStrategy to use // * @param setting - The old setting that indicates the NamingStrategy to use
* @param implicitInstead - The new setting that indicates the ImplicitNamingStrategy to use // * @param implicitInstead - The new setting that indicates the ImplicitNamingStrategy to use
* @param physicalInstead - The new setting that indicates the PhysicalNamingStrategy to use // * @param physicalInstead - The new setting that indicates the PhysicalNamingStrategy to use
*/ // */
@LogMessage(level = WARN) // @LogMessage(level = WARN)
@Message( // @Message(
value = "Attempted to specify unsupported NamingStrategy via setting [%s]; NamingStrategy " + // value = "Attempted to specify unsupported NamingStrategy via setting [%s]; NamingStrategy " +
"has been removed in favor of the split ImplicitNamingStrategy and " + // "has been removed in favor of the split ImplicitNamingStrategy and " +
"PhysicalNamingStrategy; use [%s] or [%s], respectively, instead.", // "PhysicalNamingStrategy; use [%s] or [%s], respectively, instead.",
id = 90000006 // id = 90000006
) // )
void logDeprecatedNamingStrategySetting(String setting, String implicitInstead, String physicalInstead); // void logDeprecatedNamingStrategySetting(String setting, String implicitInstead, String physicalInstead);
/** /**
* Log a warning about an attempt to specify unsupported NamingStrategy * Log a warning about an attempt to specify unsupported NamingStrategy
@ -129,14 +129,13 @@ public interface DeprecationLogger extends BasicLogger {
) )
void deprecatedManyToManyFetch(); void deprecatedManyToManyFetch();
// @LogMessage(level = WARN)
@LogMessage(level = WARN) // @Message(
@Message( // value = "org.hibernate.hql.spi.TemporaryTableBulkIdStrategy (temporary) has been deprecated in favor of the" +
value = "org.hibernate.hql.spi.TemporaryTableBulkIdStrategy (temporary) has been deprecated in favor of the" + // " more specific org.hibernate.hql.spi.id.local.LocalTemporaryTableBulkIdStrategy (local_temporary).",
" more specific org.hibernate.hql.spi.id.local.LocalTemporaryTableBulkIdStrategy (local_temporary).", // id = 90000011
id = 90000011 // )
) // void logDeprecationOfTemporaryTableBulkIdStrategy();
void logDeprecationOfTemporaryTableBulkIdStrategy();
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "Recognized obsolete hibernate namespace %s. Use namespace %s instead. Support for obsolete DTD/XSD namespaces may be removed at any time.", @Message(value = "Recognized obsolete hibernate namespace %s. Use namespace %s instead. Support for obsolete DTD/XSD namespaces may be removed at any time.",
@ -172,20 +171,20 @@ public interface DeprecationLogger extends BasicLogger {
) )
void deprecatedTableGenerator(String generatorImpl); void deprecatedTableGenerator(String generatorImpl);
@LogMessage(level = WARN) // @LogMessage(level = WARN)
@Message( // @Message(
id = 90000016, // id = 90000016,
value = "Found use of deprecated 'collection property' syntax in HQL/JPQL query [%2$s.%1$s]; " + // value = "Found use of deprecated 'collection property' syntax in HQL/JPQL query [%2$s.%1$s]; " +
"use collection function syntax instead [%1$s(%2$s)]." // "use collection function syntax instead [%1$s(%2$s)]."
) // )
void logDeprecationOfCollectionPropertiesInHql(String collectionPropertyName, String alias); // void logDeprecationOfCollectionPropertiesInHql(String collectionPropertyName, String alias);
@LogMessage(level = WARN) // @LogMessage(level = WARN)
@Message( // @Message(
id = 90000017, // id = 90000017,
value = "Found use of deprecated entity-type selector syntax in HQL/JPQL query ['%1$s.class']; use TYPE operator instead : type(%1$s)" // value = "Found use of deprecated entity-type selector syntax in HQL/JPQL query ['%1$s.class']; use TYPE operator instead : type(%1$s)"
) // )
void logDeprecationOfClassEntityTypeSelector(String path); // void logDeprecationOfClassEntityTypeSelector(String path);
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message( @Message(
@ -201,14 +200,14 @@ public interface DeprecationLogger extends BasicLogger {
// ) // )
// void logDeprecatedBytecodeEnhancement(); // void logDeprecatedBytecodeEnhancement();
@LogMessage(level = WARN) // @LogMessage(level = WARN)
@Message( // @Message(
id = 90000020, // id = 90000020,
value = "You are using the deprecated legacy bytecode enhancement Ant-task. This task is left in place for a short-time to " + // value = "You are using the deprecated legacy bytecode enhancement Ant-task. This task is left in place for a short-time to " +
"aid migrations to 5.1 and the new (vastly improved) bytecode enhancement support. This task (%s) now delegates to the" + // "aid migrations to 5.1 and the new (vastly improved) bytecode enhancement support. This task (%s) now delegates to the" +
"new Ant-task (%s) leveraging that new bytecode enhancement. You should update your build to use the new task explicitly." // "new Ant-task (%s) leveraging that new bytecode enhancement. You should update your build to use the new task explicitly."
) // )
void logDeprecatedInstrumentTask(Class taskClass, Class newTaskClass); // void logDeprecatedInstrumentTask(Class taskClass, Class newTaskClass);
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message( @Message(
@ -217,29 +216,29 @@ public interface DeprecationLogger extends BasicLogger {
) )
void deprecatedSetting(String oldSettingName, String newSettingName); void deprecatedSetting(String oldSettingName, String newSettingName);
@LogMessage(level = WARN) // @LogMessage(level = WARN)
@Message( // @Message(
id = 90000022, // id = 90000022,
value = "Hibernate's legacy org.hibernate.Criteria API is deprecated; use the JPA jakarta.persistence.criteria.CriteriaQuery instead" // value = "Hibernate's legacy org.hibernate.Criteria API is deprecated; use the JPA jakarta.persistence.criteria.CriteriaQuery instead"
) // )
void deprecatedLegacyCriteria(); // void deprecatedLegacyCriteria();
@LogMessage(level = WARN) // @LogMessage(level = WARN)
@Message( // @Message(
id = 90000024, // id = 90000024,
value = "Application requested zero be used as the base for JDBC-style parameters found in native-queries; " + // value = "Application requested zero be used as the base for JDBC-style parameters found in native-queries; " +
"this is a *temporary* backwards-compatibility setting to help applications using versions prior to " + // "this is a *temporary* backwards-compatibility setting to help applications using versions prior to " +
"5.3 in upgrading. It will be removed in a later version." // "5.3 in upgrading. It will be removed in a later version."
) // )
void logUseOfDeprecatedZeroBasedJdbcStyleParams(); // void logUseOfDeprecatedZeroBasedJdbcStyleParams();
@LogMessage(level = WARN) // @LogMessage(level = WARN)
@Message( // @Message(
id = 90000025, // id = 90000025,
value = "Encountered multiple component mappings for the same java class [%s] with different property mappings. " + // value = "Encountered multiple component mappings for the same java class [%s] with different property mappings. " +
"This is deprecated and will be removed in a future version. Every property mapping combination should have its own java class" // "This is deprecated and will be removed in a future version. Every property mapping combination should have its own java class"
) // )
void deprecatedComponentMapping(String name); // void deprecatedComponentMapping(String name);
@LogMessage(level = WARN) @LogMessage(level = WARN)
@Message(value = "%s has been deprecated", @Message(value = "%s has been deprecated",
@ -250,4 +249,15 @@ public interface DeprecationLogger extends BasicLogger {
@Message(value = "%s has been deprecated; use %s instead", @Message(value = "%s has been deprecated; use %s instead",
id = 90000026) id = 90000026)
void deprecatedDialect(String dialect, String replacement); void deprecatedDialect(String dialect, String replacement);
/**
* Different from {@link #deprecatedSetting} in that sometimes there is no
* direct alternative
*/
@LogMessage(level = WARN)
@Message(
id = 90000027,
value = "Encountered deprecated setting [%s]; instead %s"
)
void deprecatedSetting2(String settingName, String alternative);
} }

View File

@ -12,7 +12,11 @@ import java.util.Map;
* Provide a set of IdentifierGenerator strategies allowing to override the Hibernate Core default ones * Provide a set of IdentifierGenerator strategies allowing to override the Hibernate Core default ones
* *
* @author <a href="mailto:emmanuel@hibernate.org">Emmanuel Bernard</a> * @author <a href="mailto:emmanuel@hibernate.org">Emmanuel Bernard</a>
*
* @deprecated (as of 6.0) supply a {@link org.hibernate.id.factory.spi.GenerationTypeStrategyRegistration}
* instead
*/ */
@Deprecated
public interface IdentifierGeneratorStrategyProvider { public interface IdentifierGeneratorStrategyProvider {
/** /**
* set of strategy / generator class pairs to register as accepted strategies * set of strategy / generator class pairs to register as accepted strategies

View File

@ -300,7 +300,10 @@ public abstract class SimpleValue implements KeyValue {
* @return IdentifierGenerator null if * @return IdentifierGenerator null if
* {@link #createIdentifierGenerator(IdentifierGeneratorFactory, Dialect, String, String, RootClass)} was never * {@link #createIdentifierGenerator(IdentifierGeneratorFactory, Dialect, String, String, RootClass)} was never
* completed. * completed.
*
* @deprecated (as of 6.0) - not used and no longer supported.
*/ */
@Deprecated
public IdentifierGenerator getIdentifierGenerator() { public IdentifierGenerator getIdentifierGenerator() {
return identifierGenerator; return identifierGenerator;
} }