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 org.hibernate.id.factory.spi.StandardGenerator
This commit is contained in:
parent
c5ad9e129e
commit
1e8f6f9bbd
|
@ -8,6 +8,7 @@ package org.hibernate.id;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
|
import org.hibernate.id.factory.spi.StandardGenerator;
|
||||||
import org.hibernate.internal.util.BytesHelper;
|
import org.hibernate.internal.util.BytesHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +19,7 @@ import org.hibernate.internal.util.BytesHelper;
|
||||||
* @see UUIDHexGenerator
|
* @see UUIDHexGenerator
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractUUIDGenerator implements IdentifierGenerator {
|
public abstract class AbstractUUIDGenerator implements StandardGenerator {
|
||||||
|
|
||||||
private static final int IP;
|
private static final int IP;
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Properties;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.id.factory.spi.StandardGenerator;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ import org.hibernate.type.Type;
|
||||||
*
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class Assigned implements IdentifierGenerator {
|
public class Assigned implements StandardGenerator {
|
||||||
private String entityName;
|
private String entityName;
|
||||||
|
|
||||||
public Object generate(SharedSessionContractImplementor session, Object obj) throws HibernateException {
|
public Object generate(SharedSessionContractImplementor session, Object obj) throws HibernateException {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
package org.hibernate.id;
|
package org.hibernate.id;
|
||||||
|
|
||||||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||||
|
import org.hibernate.id.factory.spi.StandardGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specialized contract for {@link IdentifierGenerator} implementations capable of being used in conjunction
|
* Specialized contract for {@link IdentifierGenerator} implementations capable of being used in conjunction
|
||||||
|
@ -14,7 +15,7 @@ import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface BulkInsertionCapableIdentifierGenerator extends IdentifierGenerator {
|
public interface BulkInsertionCapableIdentifierGenerator extends StandardGenerator {
|
||||||
/**
|
/**
|
||||||
* Given the configuration of this generator, is identifier generation as part of bulk insertion supported?
|
* Given the configuration of this generator, is identifier generation as part of bulk insertion supported?
|
||||||
* <p/>
|
* <p/>
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.boot.model.relational.Database;
|
||||||
import org.hibernate.boot.model.relational.ExportableProducer;
|
import org.hibernate.boot.model.relational.ExportableProducer;
|
||||||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.id.factory.spi.StandardGenerator;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
|
||||||
|
@ -49,7 +50,8 @@ import org.hibernate.type.Type;
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class CompositeNestedGeneratedValueGenerator implements IdentifierGenerator, Serializable, IdentifierGeneratorAggregator {
|
public class CompositeNestedGeneratedValueGenerator
|
||||||
|
implements StandardGenerator, IdentifierGeneratorAggregator, Serializable {
|
||||||
/**
|
/**
|
||||||
* Contract for declaring how to locate the context for sub-value injection.
|
* Contract for declaring how to locate the context for sub-value injection.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.hibernate.StatelessSession;
|
||||||
import org.hibernate.TransientObjectException;
|
import org.hibernate.TransientObjectException;
|
||||||
import org.hibernate.engine.internal.ForeignKeys;
|
import org.hibernate.engine.internal.ForeignKeys;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.id.factory.spi.StandardGenerator;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.loader.PropertyPath;
|
import org.hibernate.loader.PropertyPath;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
@ -33,7 +34,7 @@ import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||||
*
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public class ForeignGenerator implements IdentifierGenerator {
|
public class ForeignGenerator implements StandardGenerator {
|
||||||
private static final CoreMessageLogger LOG = messageLogger( ForeignGenerator.class );
|
private static final CoreMessageLogger LOG = messageLogger( ForeignGenerator.class );
|
||||||
|
|
||||||
private String entityName;
|
private String entityName;
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.sql.SQLException;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.id.factory.spi.StandardGenerator;
|
||||||
import org.hibernate.internal.CoreLogging;
|
import org.hibernate.internal.CoreLogging;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ import org.hibernate.internal.CoreMessageLogger;
|
||||||
*
|
*
|
||||||
* @author Joseph Fifield
|
* @author Joseph Fifield
|
||||||
*/
|
*/
|
||||||
public class GUIDGenerator implements IdentifierGenerator {
|
public class GUIDGenerator implements StandardGenerator {
|
||||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( GUIDGenerator.class );
|
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( GUIDGenerator.class );
|
||||||
|
|
||||||
private static boolean WARNED;
|
private static boolean WARNED;
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||||
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
||||||
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.id.factory.spi.StandardGenerator;
|
||||||
import org.hibernate.internal.CoreLogging;
|
import org.hibernate.internal.CoreLogging;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
@ -43,7 +44,7 @@ import org.hibernate.type.Type;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
* @author Brett Meyer
|
* @author Brett Meyer
|
||||||
*/
|
*/
|
||||||
public class IncrementGenerator implements IdentifierGenerator {
|
public class IncrementGenerator implements StandardGenerator {
|
||||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( IncrementGenerator.class );
|
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( IncrementGenerator.class );
|
||||||
|
|
||||||
private Class returnClass;
|
private Class returnClass;
|
||||||
|
|
|
@ -9,11 +9,12 @@ package org.hibernate.id;
|
||||||
import org.hibernate.boot.model.relational.ExportableProducer;
|
import org.hibernate.boot.model.relational.ExportableProducer;
|
||||||
import org.hibernate.id.enhanced.Optimizer;
|
import org.hibernate.id.enhanced.Optimizer;
|
||||||
import org.hibernate.id.enhanced.StandardOptimizerDescriptor;
|
import org.hibernate.id.enhanced.StandardOptimizerDescriptor;
|
||||||
|
import org.hibernate.id.factory.spi.StandardGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commonality between sequence-based and table-based generators
|
* Commonality between sequence-based and table-based generators
|
||||||
*/
|
*/
|
||||||
public interface OptimizableGenerator extends IdentifierGenerator, ExportableProducer {
|
public interface OptimizableGenerator extends StandardGenerator, ExportableProducer {
|
||||||
/**
|
/**
|
||||||
* If an explicit sequence/table name is not configured,
|
* If an explicit sequence/table name is not configured,
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,14 +7,14 @@
|
||||||
package org.hibernate.id;
|
package org.hibernate.id;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
|
import org.hibernate.id.factory.spi.StandardGenerator;
|
||||||
import org.hibernate.id.insert.InsertGeneratedIdentifierDelegate;
|
import org.hibernate.id.insert.InsertGeneratedIdentifierDelegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public interface PostInsertIdentifierGenerator extends IdentifierGenerator {
|
public interface PostInsertIdentifierGenerator extends StandardGenerator {
|
||||||
InsertGeneratedIdentifierDelegate getInsertGeneratedIdentifierDelegate(
|
InsertGeneratedIdentifierDelegate getInsertGeneratedIdentifierDelegate(
|
||||||
PostInsertIdentityPersister persister,
|
PostInsertIdentityPersister persister,
|
||||||
Dialect dialect,
|
Dialect dialect,
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.hibernate.MappingException;
|
||||||
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.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
import org.hibernate.id.factory.spi.StandardGenerator;
|
||||||
import org.hibernate.id.uuid.StandardRandomStrategy;
|
import org.hibernate.id.uuid.StandardRandomStrategy;
|
||||||
import org.hibernate.internal.CoreLogging;
|
import org.hibernate.internal.CoreLogging;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
|
@ -40,7 +41,7 @@ import org.hibernate.type.descriptor.java.UUIDJavaTypeDescriptor;
|
||||||
* {@link org.hibernate.annotations.UuidGenerator} instead
|
* {@link org.hibernate.annotations.UuidGenerator} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public class UUIDGenerator implements IdentifierGenerator {
|
public class UUIDGenerator implements StandardGenerator {
|
||||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( UUIDGenerator.class );
|
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( UUIDGenerator.class );
|
||||||
|
|
||||||
public static final String UUID_GEN_STRATEGY = "uuid_gen_strategy";
|
public static final String UUID_GEN_STRATEGY = "uuid_gen_strategy";
|
||||||
|
|
|
@ -32,6 +32,7 @@ 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.IdentifierGeneratorFactory;
|
import org.hibernate.id.factory.IdentifierGeneratorFactory;
|
||||||
|
import org.hibernate.id.factory.spi.StandardGenerator;
|
||||||
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;
|
||||||
|
@ -148,7 +149,9 @@ public class StandardIdentifierGeneratorFactory
|
||||||
final Class<? extends IdentifierGenerator> clazz = getIdentifierGeneratorClass( strategy );
|
final Class<? extends IdentifierGenerator> clazz = getIdentifierGeneratorClass( strategy );
|
||||||
final IdentifierGenerator identifierGenerator;
|
final IdentifierGenerator identifierGenerator;
|
||||||
|
|
||||||
if ( beanContainer == null || legacyGeneratorClassNameMap.containsKey( strategy ) ) {
|
if ( beanContainer == null
|
||||||
|
|| StandardGenerator.class.isAssignableFrom( clazz )
|
||||||
|
|| legacyGeneratorClassNameMap.containsKey( strategy ) ) {
|
||||||
identifierGenerator = clazz.newInstance();
|
identifierGenerator = clazz.newInstance();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
* 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.id.IdentifierGenerator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marker interface for Hibernate-provided generator impls
|
||||||
|
*/
|
||||||
|
public interface StandardGenerator extends IdentifierGenerator {
|
||||||
|
}
|
|
@ -15,6 +15,7 @@ import org.hibernate.HibernateException;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.id.IdentifierGenerator;
|
import org.hibernate.id.IdentifierGenerator;
|
||||||
import org.hibernate.id.factory.spi.CustomIdGeneratorCreationContext;
|
import org.hibernate.id.factory.spi.CustomIdGeneratorCreationContext;
|
||||||
|
import org.hibernate.id.factory.spi.StandardGenerator;
|
||||||
import org.hibernate.type.descriptor.java.UUIDJavaTypeDescriptor;
|
import org.hibernate.type.descriptor.java.UUIDJavaTypeDescriptor;
|
||||||
import org.hibernate.type.descriptor.java.UUIDJavaTypeDescriptor.ValueTransformer;
|
import org.hibernate.type.descriptor.java.UUIDJavaTypeDescriptor.ValueTransformer;
|
||||||
|
|
||||||
|
@ -25,7 +26,7 @@ import static org.hibernate.annotations.UuidGenerator.Style.TIME;
|
||||||
*
|
*
|
||||||
* @see org.hibernate.annotations.UuidGenerator
|
* @see org.hibernate.annotations.UuidGenerator
|
||||||
*/
|
*/
|
||||||
public class UuidGenerator implements IdentifierGenerator {
|
public class UuidGenerator implements StandardGenerator {
|
||||||
interface ValueGenerator {
|
interface ValueGenerator {
|
||||||
UUID generateUuid(SharedSessionContractImplementor session);
|
UUID generateUuid(SharedSessionContractImplementor session);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue