Package org.hibernate.id
Interface IdentifierGenerator
-
- All Superinterfaces:
Configurable,ExportableProducer
- All Known Subinterfaces:
BulkInsertionCapableIdentifierGenerator,PersistentIdentifierGenerator,PostInsertIdentifierGenerator
- All Known Implementing Classes:
AbstractPostInsertGenerator,AbstractUUIDGenerator,Assigned,CompositeNestedGeneratedValueGenerator,ForeignGenerator,GUIDGenerator,IdentityGenerator,IncrementGenerator,MultipleHiLoPerTableGenerator,SelectGenerator,SequenceGenerator,SequenceHiLoGenerator,SequenceIdentityGenerator,SequenceStyleGenerator,TableGenerator,UUIDGenerator,UUIDHexGenerator
public interface IdentifierGenerator extends Configurable, ExportableProducer
The general contract between a class that generates unique identifiers and the Session. It is not intended that this interface ever be exposed to the application. It is intended that users implement this interface to provide custom identifier generation strategies.
Implementors should provide a public default constructor.
Implementations that accept configuration parameters should also implement Configurable.
Implementors must be thread-safe- See Also:
PersistentIdentifierGenerator
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringENTITY_NAMEThe configuration parameter holding the entity namestatic java.lang.StringGENERATOR_NAMEUsed as a key to pass the name used asGeneratedValue.generator()to theIdentifierGeneratoras it is configured.static java.lang.StringJPA_ENTITY_NAMEThe configuration parameter holding the JPA entity name
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidconfigure(Type type, java.util.Properties params, ServiceRegistry serviceRegistry)Configure this instance, given the value of parameters specified by the user as <param> elements.java.io.Serializablegenerate(SharedSessionContractImplementor session, java.lang.Object object)Generate a new identifier.default voidinitialize(SqlStringGenerationContext context)Initializes this instance, in particular pre-generates SQL as necessary.default voidregisterExportables(Database database)Register database objects used by this identifier generator, e.g.default booleansupportsJdbcBatchInserts()Check if JDBC batch inserts are supported.
-
-
-
Field Detail
-
ENTITY_NAME
static final java.lang.String ENTITY_NAME
The configuration parameter holding the entity name- See Also:
- Constant Field Values
-
JPA_ENTITY_NAME
static final java.lang.String JPA_ENTITY_NAME
The configuration parameter holding the JPA entity name- See Also:
- Constant Field Values
-
GENERATOR_NAME
static final java.lang.String GENERATOR_NAME
Used as a key to pass the name used asGeneratedValue.generator()to theIdentifierGeneratoras it is configured.- See Also:
- Constant Field Values
-
-
Method Detail
-
configure
default void configure(Type type, java.util.Properties params, ServiceRegistry serviceRegistry) throws MappingException
Configure 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 descriptorparams- param values, keyed by parameter nameserviceRegistry- Access to service that may be needed.- Throws:
MappingException- If configuration fails.
-
registerExportables
default void registerExportables(Database database)
Register database objects used by this identifier generator, e.g. sequences, tables, etc.This method is called just once, after
configure(Type, Properties, ServiceRegistry).- Specified by:
registerExportablesin interfaceExportableProducer- Parameters:
database- The database instance
-
initialize
default void initialize(SqlStringGenerationContext context)
Initializes this instance, in particular pre-generates SQL as necessary.This method is called after
registerExportables(Database), before first use.- Parameters:
context- A context to help generate SQL strings
-
generate
java.io.Serializable generate(SharedSessionContractImplementor session, java.lang.Object object) throws HibernateException
Generate a new identifier.- Parameters:
session- The session from which the request originatesobject- the entity or collection (idbag) for which the id is being generated- Returns:
- a new identifier
- Throws:
HibernateException- Indicates trouble generating the identifier
-
supportsJdbcBatchInserts
default boolean supportsJdbcBatchInserts()
Check if JDBC batch inserts are supported.- Returns:
- JDBC batch inserts are supported.
-
-