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:
parent
3c97ac2077
commit
848c9f0914
|
@ -14,8 +14,10 @@ import jakarta.persistence.TableGenerator;
|
|||
/**
|
||||
* 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 {
|
||||
interface GeneratorNameDeterminationContext {
|
||||
/**
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.hibernate.boot.registry.classloading.internal.TcclLookupPrecedence;
|
|||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.cache.spi.TimestampsCacheFactory;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
|
||||
import org.hibernate.id.factory.spi.GenerationTypeStrategy;
|
||||
import org.hibernate.jpa.spi.JpaCompliance;
|
||||
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
|
||||
import org.hibernate.query.hql.HqlTranslator;
|
||||
|
@ -2589,7 +2590,11 @@ public interface AvailableSettings {
|
|||
|
||||
/**
|
||||
* 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";
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,7 +20,10 @@ import org.hibernate.internal.CoreMessageLogger;
|
|||
* Generates <tt>string</tt> values using the SQL Server NEWID() function.
|
||||
*
|
||||
* @author Joseph Fifield
|
||||
*
|
||||
* @deprecated (as of 6.0)
|
||||
*/
|
||||
@Deprecated
|
||||
public class GUIDGenerator implements StandardGenerator {
|
||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( GUIDGenerator.class );
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ import org.jboss.logging.Logger;
|
|||
/**
|
||||
* Logging related to IdentifierGeneratorFactory
|
||||
*/
|
||||
public class IdGenCreationLogging {
|
||||
public static final Logger ID_GEN_LOGGER = Logger.getLogger( "org.hibernate.orm.idgen.factory" );
|
||||
public class IdGenFactoryLogging {
|
||||
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_DEBUG_ENABLE = ID_GEN_LOGGER.isDebugEnabled();
|
||||
public static final boolean IS_TRACE_ENABLE = ID_GEN_FAC_LOGGER.isTraceEnabled();
|
||||
public static final boolean IS_DEBUG_ENABLE = ID_GEN_FAC_LOGGER.isDebugEnabled();
|
||||
}
|
|
@ -10,7 +10,11 @@ import java.util.Properties;
|
|||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.id.IdentifierGenerator;
|
||||
import org.hibernate.id.factory.spi.GeneratorDefinitionResolver;
|
||||
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.
|
||||
|
@ -25,6 +29,17 @@ public interface IdentifierGeneratorFactory {
|
|||
*/
|
||||
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.
|
||||
*
|
||||
|
@ -33,7 +48,11 @@ public interface IdentifierGeneratorFactory {
|
|||
* @param config Any configuration properties given in the generator mapping.
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
|
@ -41,6 +60,10 @@ public interface IdentifierGeneratorFactory {
|
|||
*
|
||||
* @param strategy The strategy
|
||||
* @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);
|
||||
}
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
}
|
|
@ -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() );
|
||||
}
|
||||
}
|
|
@ -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() );
|
||||
}
|
||||
}
|
|
@ -7,11 +7,13 @@
|
|||
package org.hibernate.id.factory.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||
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.enhanced.SequenceStyleGenerator;
|
||||
import org.hibernate.id.enhanced.TableGenerator;
|
||||
import org.hibernate.id.factory.IdGenFactoryLogging;
|
||||
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.internal.log.DeprecationLogger;
|
||||
import org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider;
|
||||
import org.hibernate.resource.beans.container.spi.BeanContainer;
|
||||
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.service.ServiceRegistry;
|
||||
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.
|
||||
|
@ -53,6 +63,7 @@ import static org.hibernate.id.factory.IdGenCreationLogging.ID_GEN_LOGGER;
|
|||
public class StandardIdentifierGeneratorFactory
|
||||
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 ServiceRegistry serviceRegistry;
|
||||
|
@ -91,18 +102,44 @@ public class StandardIdentifierGeneratorFactory
|
|||
this.serviceRegistry = serviceRegistry;
|
||||
|
||||
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;
|
||||
}
|
||||
else {
|
||||
this.beanContainer = serviceRegistry.getService( ManagedBeanRegistry.class ).getBeanContainer();
|
||||
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( "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.hex", UUIDHexGenerator.class ); // uuid.hex is deprecated
|
||||
register( "assigned", Assigned.class );
|
||||
|
@ -117,6 +154,10 @@ public class StandardIdentifierGeneratorFactory
|
|||
final ConfigurationService configService = serviceRegistry.getService( ConfigurationService.class );
|
||||
final Object providerSetting = configService.getSettings().get( AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER );
|
||||
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(
|
||||
IdentifierGeneratorStrategyProvider.class,
|
||||
providerSetting
|
||||
|
@ -128,13 +169,35 @@ public class StandardIdentifierGeneratorFactory
|
|||
}
|
||||
|
||||
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 );
|
||||
if ( previous != null && ID_GEN_LOGGER.isDebugEnabled() ) {
|
||||
ID_GEN_LOGGER.debugf( " - overriding [%s]", previous.getName() );
|
||||
if ( previous != null && ID_GEN_FAC_LOGGER.isDebugEnabled() ) {
|
||||
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
|
||||
public Dialect getDialect() {
|
||||
if ( dialect == null ) {
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -177,9 +177,9 @@ public interface CoreMessageLogger extends BasicLogger {
|
|||
@Message(value = "Defining %s=true ignored in HEM", id = 59)
|
||||
void definingFlushBeforeCompletionIgnoredInHem(String flushBeforeCompletion);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(value = "@ForceDiscriminator is deprecated use @DiscriminatorOptions instead.", id = 62)
|
||||
void deprecatedForceDescriminatorAnnotation();
|
||||
// @LogMessage(level = WARN)
|
||||
// @Message(value = "@ForceDiscriminator is deprecated use @DiscriminatorOptions instead.", id = 62)
|
||||
// void deprecatedForceDescriminatorAnnotation();
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(value = "DEPRECATED : use [%s] instead with custom [%s] implementation", id = 65)
|
||||
|
|
|
@ -42,16 +42,16 @@ public interface DeprecationLogger extends BasicLogger {
|
|||
)
|
||||
public void logDeprecatedScannerSetting();
|
||||
|
||||
/**
|
||||
* Log message indicating the use of features that were only useful for DOM4J EntityMode,
|
||||
* which was removed a long time ago.
|
||||
*/
|
||||
@LogMessage( level = WARN )
|
||||
@Message(
|
||||
value = "Use of DOM4J entity-mode is considered deprecated",
|
||||
id = 90000003
|
||||
)
|
||||
public void logDeprecationOfDomEntityModeSupport();
|
||||
// /**
|
||||
// * Log message indicating the use of features that were only useful for DOM4J EntityMode,
|
||||
// * which was removed a long time ago.
|
||||
// */
|
||||
// @LogMessage( level = WARN )
|
||||
// @Message(
|
||||
// value = "Use of DOM4J entity-mode is considered deprecated",
|
||||
// id = 90000003
|
||||
// )
|
||||
// public void logDeprecationOfDomEntityModeSupport();
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
|
@ -69,21 +69,21 @@ public interface DeprecationLogger extends BasicLogger {
|
|||
)
|
||||
public void logDeprecationOfNonNamedIdAttribute(String entityName);
|
||||
|
||||
/**
|
||||
* Log a warning about an attempt to specify no-longer-supported NamingStrategy
|
||||
*
|
||||
* @param setting - The old setting that indicates the NamingStrategy to use
|
||||
* @param implicitInstead - The new setting that indicates the ImplicitNamingStrategy to use
|
||||
* @param physicalInstead - The new setting that indicates the PhysicalNamingStrategy to use
|
||||
*/
|
||||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
value = "Attempted to specify unsupported NamingStrategy via setting [%s]; NamingStrategy " +
|
||||
"has been removed in favor of the split ImplicitNamingStrategy and " +
|
||||
"PhysicalNamingStrategy; use [%s] or [%s], respectively, instead.",
|
||||
id = 90000006
|
||||
)
|
||||
void logDeprecatedNamingStrategySetting(String setting, String implicitInstead, String physicalInstead);
|
||||
// /**
|
||||
// * Log a warning about an attempt to specify no-longer-supported NamingStrategy
|
||||
// *
|
||||
// * @param setting - The old setting that indicates the NamingStrategy to use
|
||||
// * @param implicitInstead - The new setting that indicates the ImplicitNamingStrategy to use
|
||||
// * @param physicalInstead - The new setting that indicates the PhysicalNamingStrategy to use
|
||||
// */
|
||||
// @LogMessage(level = WARN)
|
||||
// @Message(
|
||||
// value = "Attempted to specify unsupported NamingStrategy via setting [%s]; NamingStrategy " +
|
||||
// "has been removed in favor of the split ImplicitNamingStrategy and " +
|
||||
// "PhysicalNamingStrategy; use [%s] or [%s], respectively, instead.",
|
||||
// id = 90000006
|
||||
// )
|
||||
// void logDeprecatedNamingStrategySetting(String setting, String implicitInstead, String physicalInstead);
|
||||
|
||||
/**
|
||||
* Log a warning about an attempt to specify unsupported NamingStrategy
|
||||
|
@ -129,14 +129,13 @@ public interface DeprecationLogger extends BasicLogger {
|
|||
)
|
||||
void deprecatedManyToManyFetch();
|
||||
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
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).",
|
||||
id = 90000011
|
||||
)
|
||||
void logDeprecationOfTemporaryTableBulkIdStrategy();
|
||||
// @LogMessage(level = WARN)
|
||||
// @Message(
|
||||
// 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).",
|
||||
// id = 90000011
|
||||
// )
|
||||
// void logDeprecationOfTemporaryTableBulkIdStrategy();
|
||||
|
||||
@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.",
|
||||
|
@ -172,20 +171,20 @@ public interface DeprecationLogger extends BasicLogger {
|
|||
)
|
||||
void deprecatedTableGenerator(String generatorImpl);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
id = 90000016,
|
||||
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)]."
|
||||
)
|
||||
void logDeprecationOfCollectionPropertiesInHql(String collectionPropertyName, String alias);
|
||||
// @LogMessage(level = WARN)
|
||||
// @Message(
|
||||
// id = 90000016,
|
||||
// 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)]."
|
||||
// )
|
||||
// void logDeprecationOfCollectionPropertiesInHql(String collectionPropertyName, String alias);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
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)"
|
||||
)
|
||||
void logDeprecationOfClassEntityTypeSelector(String path);
|
||||
// @LogMessage(level = WARN)
|
||||
// @Message(
|
||||
// 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)"
|
||||
// )
|
||||
// void logDeprecationOfClassEntityTypeSelector(String path);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
|
@ -201,14 +200,14 @@ public interface DeprecationLogger extends BasicLogger {
|
|||
// )
|
||||
// void logDeprecatedBytecodeEnhancement();
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
id = 90000020,
|
||||
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" +
|
||||
"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);
|
||||
// @LogMessage(level = WARN)
|
||||
// @Message(
|
||||
// id = 90000020,
|
||||
// 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" +
|
||||
// "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);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
|
@ -217,29 +216,29 @@ public interface DeprecationLogger extends BasicLogger {
|
|||
)
|
||||
void deprecatedSetting(String oldSettingName, String newSettingName);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
id = 90000022,
|
||||
value = "Hibernate's legacy org.hibernate.Criteria API is deprecated; use the JPA jakarta.persistence.criteria.CriteriaQuery instead"
|
||||
)
|
||||
void deprecatedLegacyCriteria();
|
||||
// @LogMessage(level = WARN)
|
||||
// @Message(
|
||||
// id = 90000022,
|
||||
// value = "Hibernate's legacy org.hibernate.Criteria API is deprecated; use the JPA jakarta.persistence.criteria.CriteriaQuery instead"
|
||||
// )
|
||||
// void deprecatedLegacyCriteria();
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
id = 90000024,
|
||||
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 " +
|
||||
"5.3 in upgrading. It will be removed in a later version."
|
||||
)
|
||||
void logUseOfDeprecatedZeroBasedJdbcStyleParams();
|
||||
// @LogMessage(level = WARN)
|
||||
// @Message(
|
||||
// id = 90000024,
|
||||
// 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 " +
|
||||
// "5.3 in upgrading. It will be removed in a later version."
|
||||
// )
|
||||
// void logUseOfDeprecatedZeroBasedJdbcStyleParams();
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(
|
||||
id = 90000025,
|
||||
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"
|
||||
)
|
||||
void deprecatedComponentMapping(String name);
|
||||
// @LogMessage(level = WARN)
|
||||
// @Message(
|
||||
// id = 90000025,
|
||||
// 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"
|
||||
// )
|
||||
// void deprecatedComponentMapping(String name);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(value = "%s has been deprecated",
|
||||
|
@ -250,4 +249,15 @@ public interface DeprecationLogger extends BasicLogger {
|
|||
@Message(value = "%s has been deprecated; use %s instead",
|
||||
id = 90000026)
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,11 @@ import java.util.Map;
|
|||
* Provide a set of IdentifierGenerator strategies allowing to override the Hibernate Core default ones
|
||||
*
|
||||
* @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 {
|
||||
/**
|
||||
* set of strategy / generator class pairs to register as accepted strategies
|
||||
|
|
|
@ -300,7 +300,10 @@ public abstract class SimpleValue implements KeyValue {
|
|||
* @return IdentifierGenerator null if
|
||||
* {@link #createIdentifierGenerator(IdentifierGeneratorFactory, Dialect, String, String, RootClass)} was never
|
||||
* completed.
|
||||
*
|
||||
* @deprecated (as of 6.0) - not used and no longer supported.
|
||||
*/
|
||||
@Deprecated
|
||||
public IdentifierGenerator getIdentifierGenerator() {
|
||||
return identifierGenerator;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue