Interface IdentifierGenerator
- All Superinterfaces:
BeforeExecutionGenerator,Configurable,ExportableProducer,Generator,Serializable
- All Known Subinterfaces:
OptimizableGenerator,PersistentIdentifierGenerator
- All Known Implementing Classes:
AbstractUUIDGenerator,CompositeNestedGeneratedValueGenerator,ForeignGenerator,GUIDGenerator,IncrementGenerator,OrderedSequenceGenerator,SequenceStyleGenerator,TableGenerator,UUIDGenerator,UUIDHexGenerator
BeforeExecutionGenerator with timing EventTypeSets.INSERT_ONLY
may now be used.
This interface extends BeforeExecutionGenerator with some additional
machinery for configuration, and for caching
generated SQL.
Any identifier generator, including a generator which directly implements
BeforeExecutionGenerator, may also implement ExportableProducer.
For the sake of convenience, PersistentIdentifierGenerator extends
ExportableProducer, in case the implementation needs to export
objects to the database as part of the process of schema export.
The Configurable.configure(GeneratorCreationContext, Properties) method accepts
a properties object containing named values. These include:
- several "standard" parameters with keys defined as static members of this interface: "entity_name", "jpa_entity_name", "GENERATOR_NAME", "CONTRIBUTOR", along with
- additional hardcoded parameters supplied by Hibernate to its built-in generators, depending on the generator class, and, possibly,
- parameters specified
using
GenericGenerator.parameters().
It's not usually correct to use an IdentifierGenerator with the
IdGeneratorType meta-annotation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe contributor that contributed this generatorstatic final StringThe configuration parameter holding the entity namestatic final StringThe configuration parameter holding the name of this identifier generator.static final StringThe configuration parameter holding the JPA entity name -
Method Summary
Modifier and TypeMethodDescriptiondefault voidconfigure(Type type, Properties parameters, ServiceRegistry serviceRegistry) Deprecated, for removal: This API element is subject to removal in a future version.since it overrides a deprecated methodgenerate(SharedSessionContractImplementor session, Object object) Generate a new identifier.default Objectgenerate(SharedSessionContractImplementor session, Object owner, Object currentValue, EventType eventType) Generate a value.The event types for which this generator should be called to produce a new value.default voidregisterExportables(Database database) Register database objects used by this identifier generator, for example, a sequence or tables.Methods inherited from interface org.hibernate.generator.BeforeExecutionGenerator
generatedOnExecutionMethods inherited from interface org.hibernate.id.Configurable
configure, initializeMethods inherited from interface org.hibernate.generator.Generator
allowAssignedIdentifiers, allowMutation, generatedBeforeExecution, generatedOnExecution, generatesOnInsert, generatesOnUpdate, generatesSometimes
-
Field Details
-
ENTITY_NAME
The configuration parameter holding the entity name- See Also:
-
JPA_ENTITY_NAME
The configuration parameter holding the JPA entity name- See Also:
-
GENERATOR_NAME
The configuration parameter holding the name of this identifier generator. -
CONTRIBUTOR_NAME
The contributor that contributed this generator- See Also:
-
-
Method Details
-
configure
@Deprecated(since="7.0", forRemoval=true) default void configure(Type type, Properties parameters, ServiceRegistry serviceRegistry) Deprecated, for removal: This API element is subject to removal in a future version.since it overrides a deprecated methodConfigure this instance, given the value of parameters specified by the user as<param>elements.This method is called just once, following instantiation, and before
registerExportables(Database).- Specified by:
configurein interfaceConfigurable- Parameters:
type- The id property type descriptorparameters- param values, keyed by parameter nameserviceRegistry- Access to service that may be needed.- Throws:
MappingException- If configuration fails.
-
registerExportables
Register database objects used by this identifier generator, for example, a sequence or tables.This method is called just once, after
Configurable.configure(GeneratorCreationContext, Properties).- Specified by:
registerExportablesin interfaceExportableProducer- Parameters:
database- The database instance
-
getEventTypes
Description copied from interface:GeneratorThe event types for which this generator should be called to produce a new value.Identifier generators must return
EventTypeSets.INSERT_ONLY.- Specified by:
getEventTypesin interfaceGenerator- Returns:
EventTypeSets.INSERT_ONLY
-