diff --git a/hibernate-core/src/main/java/org/hibernate/id/AbstractUUIDGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/AbstractUUIDGenerator.java index edb29441f8..2d8493e4ae 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/AbstractUUIDGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/AbstractUUIDGenerator.java @@ -8,6 +8,7 @@ package org.hibernate.id; import java.net.InetAddress; +import org.hibernate.id.factory.spi.StandardGenerator; import org.hibernate.internal.util.BytesHelper; /** @@ -18,7 +19,7 @@ import org.hibernate.internal.util.BytesHelper; * @see UUIDHexGenerator * @author Gavin King */ -public abstract class AbstractUUIDGenerator implements IdentifierGenerator { +public abstract class AbstractUUIDGenerator implements StandardGenerator { private static final int IP; static { diff --git a/hibernate-core/src/main/java/org/hibernate/id/Assigned.java b/hibernate-core/src/main/java/org/hibernate/id/Assigned.java index 9e1174d49c..31d17ecba8 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/Assigned.java +++ b/hibernate-core/src/main/java/org/hibernate/id/Assigned.java @@ -11,6 +11,7 @@ import java.util.Properties; import org.hibernate.HibernateException; import org.hibernate.MappingException; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.id.factory.spi.StandardGenerator; import org.hibernate.service.ServiceRegistry; import org.hibernate.type.Type; @@ -22,7 +23,7 @@ import org.hibernate.type.Type; * * @author Gavin King */ -public class Assigned implements IdentifierGenerator { +public class Assigned implements StandardGenerator { private String entityName; public Object generate(SharedSessionContractImplementor session, Object obj) throws HibernateException { diff --git a/hibernate-core/src/main/java/org/hibernate/id/BulkInsertionCapableIdentifierGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/BulkInsertionCapableIdentifierGenerator.java index 371b8d0f77..6b27b45b3e 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/BulkInsertionCapableIdentifierGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/BulkInsertionCapableIdentifierGenerator.java @@ -7,6 +7,7 @@ package org.hibernate.id; 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 @@ -14,7 +15,7 @@ import org.hibernate.boot.model.relational.SqlStringGenerationContext; * * @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? *
diff --git a/hibernate-core/src/main/java/org/hibernate/id/CompositeNestedGeneratedValueGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/CompositeNestedGeneratedValueGenerator.java index a0c6bdbc57..8ee2295721 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/CompositeNestedGeneratedValueGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/CompositeNestedGeneratedValueGenerator.java @@ -16,6 +16,7 @@ import org.hibernate.boot.model.relational.Database; import org.hibernate.boot.model.relational.ExportableProducer; import org.hibernate.boot.model.relational.SqlStringGenerationContext; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.id.factory.spi.StandardGenerator; import org.hibernate.service.ServiceRegistry; import org.hibernate.type.Type; @@ -49,7 +50,8 @@ import org.hibernate.type.Type; * * @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. */ diff --git a/hibernate-core/src/main/java/org/hibernate/id/ForeignGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/ForeignGenerator.java index fed815a172..ec34d6301c 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/ForeignGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/ForeignGenerator.java @@ -14,6 +14,7 @@ import org.hibernate.StatelessSession; import org.hibernate.TransientObjectException; import org.hibernate.engine.internal.ForeignKeys; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.id.factory.spi.StandardGenerator; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.loader.PropertyPath; import org.hibernate.persister.entity.EntityPersister; @@ -33,7 +34,7 @@ import static org.hibernate.internal.CoreLogging.messageLogger; * * @author Gavin King */ -public class ForeignGenerator implements IdentifierGenerator { +public class ForeignGenerator implements StandardGenerator { private static final CoreMessageLogger LOG = messageLogger( ForeignGenerator.class ); private String entityName; diff --git a/hibernate-core/src/main/java/org/hibernate/id/GUIDGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/GUIDGenerator.java index 15d5fd2d0d..be52bceae5 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/GUIDGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/GUIDGenerator.java @@ -12,6 +12,7 @@ import java.sql.SQLException; import org.hibernate.HibernateException; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.id.factory.spi.StandardGenerator; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; @@ -20,7 +21,7 @@ import org.hibernate.internal.CoreMessageLogger; * * @author Joseph Fifield */ -public class GUIDGenerator implements IdentifierGenerator { +public class GUIDGenerator implements StandardGenerator { private static final CoreMessageLogger LOG = CoreLogging.messageLogger( GUIDGenerator.class ); private static boolean WARNED; diff --git a/hibernate-core/src/main/java/org/hibernate/id/IncrementGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/IncrementGenerator.java index ec0dbac04d..63ad76e4b6 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/IncrementGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/IncrementGenerator.java @@ -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.JdbcEnvironment; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.id.factory.spi.StandardGenerator; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.StringHelper; @@ -43,7 +44,7 @@ import org.hibernate.type.Type; * @author Steve Ebersole * @author Brett Meyer */ -public class IncrementGenerator implements IdentifierGenerator { +public class IncrementGenerator implements StandardGenerator { private static final CoreMessageLogger LOG = CoreLogging.messageLogger( IncrementGenerator.class ); private Class returnClass; diff --git a/hibernate-core/src/main/java/org/hibernate/id/OptimizableGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/OptimizableGenerator.java index fe4b826948..de198e6fe5 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/OptimizableGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/OptimizableGenerator.java @@ -9,11 +9,12 @@ package org.hibernate.id; import org.hibernate.boot.model.relational.ExportableProducer; import org.hibernate.id.enhanced.Optimizer; import org.hibernate.id.enhanced.StandardOptimizerDescriptor; +import org.hibernate.id.factory.spi.StandardGenerator; /** * 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, */ diff --git a/hibernate-core/src/main/java/org/hibernate/id/PostInsertIdentifierGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/PostInsertIdentifierGenerator.java index 8fc44924aa..2d6d4e93b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/PostInsertIdentifierGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/PostInsertIdentifierGenerator.java @@ -7,14 +7,14 @@ package org.hibernate.id; import org.hibernate.HibernateException; -import org.hibernate.boot.model.relational.SqlStringGenerationContext; import org.hibernate.dialect.Dialect; +import org.hibernate.id.factory.spi.StandardGenerator; import org.hibernate.id.insert.InsertGeneratedIdentifierDelegate; /** * @author Gavin King */ -public interface PostInsertIdentifierGenerator extends IdentifierGenerator { +public interface PostInsertIdentifierGenerator extends StandardGenerator { InsertGeneratedIdentifierDelegate getInsertGeneratedIdentifierDelegate( PostInsertIdentityPersister persister, Dialect dialect, diff --git a/hibernate-core/src/main/java/org/hibernate/id/UUIDGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/UUIDGenerator.java index be17a2ec5c..e022695454 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/UUIDGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/UUIDGenerator.java @@ -14,6 +14,7 @@ import org.hibernate.MappingException; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.boot.registry.classloading.spi.ClassLoadingException; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.id.factory.spi.StandardGenerator; import org.hibernate.id.uuid.StandardRandomStrategy; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; @@ -40,7 +41,7 @@ import org.hibernate.type.descriptor.java.UUIDJavaTypeDescriptor; * {@link org.hibernate.annotations.UuidGenerator} instead */ @Deprecated -public class UUIDGenerator implements IdentifierGenerator { +public class UUIDGenerator implements StandardGenerator { private static final CoreMessageLogger LOG = CoreLogging.messageLogger( UUIDGenerator.class ); public static final String UUID_GEN_STRATEGY = "uuid_gen_strategy"; diff --git a/hibernate-core/src/main/java/org/hibernate/id/factory/internal/StandardIdentifierGeneratorFactory.java b/hibernate-core/src/main/java/org/hibernate/id/factory/internal/StandardIdentifierGeneratorFactory.java index 7aab7010a5..1930769c98 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/factory/internal/StandardIdentifierGeneratorFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/id/factory/internal/StandardIdentifierGeneratorFactory.java @@ -32,6 +32,7 @@ import org.hibernate.id.UUIDHexGenerator; import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.id.enhanced.TableGenerator; import org.hibernate.id.factory.IdentifierGeneratorFactory; +import org.hibernate.id.factory.spi.StandardGenerator; import org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider; import org.hibernate.resource.beans.container.spi.BeanContainer; import org.hibernate.resource.beans.container.spi.ContainedBean; @@ -148,7 +149,9 @@ public class StandardIdentifierGeneratorFactory final Class extends IdentifierGenerator> clazz = getIdentifierGeneratorClass( strategy ); final IdentifierGenerator identifierGenerator; - if ( beanContainer == null || legacyGeneratorClassNameMap.containsKey( strategy ) ) { + if ( beanContainer == null + || StandardGenerator.class.isAssignableFrom( clazz ) + || legacyGeneratorClassNameMap.containsKey( strategy ) ) { identifierGenerator = clazz.newInstance(); } else { diff --git a/hibernate-core/src/main/java/org/hibernate/id/factory/spi/StandardGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/factory/spi/StandardGenerator.java new file mode 100644 index 0000000000..b7689fba19 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/id/factory/spi/StandardGenerator.java @@ -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 { +} diff --git a/hibernate-core/src/main/java/org/hibernate/id/uuid/UuidGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/uuid/UuidGenerator.java index 57ed7fa1ff..4af8e27fe1 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/uuid/UuidGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/uuid/UuidGenerator.java @@ -15,6 +15,7 @@ import org.hibernate.HibernateException; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.id.IdentifierGenerator; 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.ValueTransformer; @@ -25,7 +26,7 @@ import static org.hibernate.annotations.UuidGenerator.Style.TIME; * * @see org.hibernate.annotations.UuidGenerator */ -public class UuidGenerator implements IdentifierGenerator { +public class UuidGenerator implements StandardGenerator { interface ValueGenerator { UUID generateUuid(SharedSessionContractImplementor session); }