Top Description Fields Methods
org.hibernate.id

public Interface IdentifierGenerator

extends Configurable, ExportableProducer
Known Direct Subinterfaces
org.hibernate.id.PersistentIdentifierGenerator, org.hibernate.id.PostInsertIdentifierGenerator, org.hibernate.id.BulkInsertionCapableIdentifierGenerator
Known Direct Implementers
org.hibernate.id.IncrementGenerator, org.hibernate.id.UUIDGenerator, org.hibernate.id.AbstractUUIDGenerator, org.hibernate.id.Assigned, org.hibernate.id.CompositeNestedGeneratedValueGenerator, org.hibernate.id.ForeignGenerator, org.hibernate.id.GUIDGenerator
Imports
java.io.Serializable, java.util.Properties, javax.persistence.GeneratedValue, org.hibernate.HibernateException, .MappingException, org.hibernate.boot.model.relational.Database, .ExportableProducer, .SqlStringGenerationContext, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.service.ServiceRegistry, org.hibernate.type.Type

Deprecated

as a consequence of Configurable being deprecated. See corresponding docs for further information.

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
Author
Gavin King
See Also
PersistentIdentifierGenerator

Field Summary

Modifier and TypeField and Description
public static final String
ENTITY_NAME

The configuration parameter holding the entity name

public static final String
GENERATOR_NAME

Used as a key to pass the name used as GeneratedValue#generator() to the IdentifierGenerator as it is configured.

public static final String
JPA_ENTITY_NAME

The configuration parameter holding the JPA entity name

Method Summary

Modifier and TypeMethod and Description
public default void
configure(Type
The id property type descriptor
type
,
Properties
param values, keyed by parameter name
params
,
ServiceRegistry
Access to service that may be needed.
serviceRegistry
)

Implements org.hibernate.id.Configurable.configure.

Configure this instance, given the value of parameters specified by the user as <param> elements.
public Serializable

Returns:

a new identifier
generate
(SharedSessionContractImplementor
The session from which the request originates
session
,
Object
the entity or collection (idbag) for which the id is being generated
object
)

Generate a new identifier.

public default void
initialize(SqlStringGenerationContext
A context to help generate SQL strings
context
)

Initializes this instance, in particular pre-generates SQL as necessary.

public default void
registerExportables(Database
The database instance
database
)

Implements org.hibernate.boot.model.relational.ExportableProducer.registerExportables.

Register database objects used by this identifier generator, e.g. sequences, tables, etc.

This method is called just once, after configure(Type, Properties, ServiceRegistry).

public default boolean

Returns:

JDBC batch inserts are supported.
supportsJdbcBatchInserts
()

Check if JDBC batch inserts are supported.

Field Detail

ENTITY_NAMEback to summary
public static final String ENTITY_NAME

The configuration parameter holding the entity name

GENERATOR_NAMEback to summary
public static final String GENERATOR_NAME

Used as a key to pass the name used as GeneratedValue#generator() to the IdentifierGenerator as it is configured.

JPA_ENTITY_NAMEback to summary
public static final String JPA_ENTITY_NAME

The configuration parameter holding the JPA entity name

Method Detail

configureback to summary
public default void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException

Implements org.hibernate.id.Configurable.configure.

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).

Parameters
type:Type

The id property type descriptor

params:Properties

param values, keyed by parameter name

serviceRegistry:ServiceRegistry

Access to service that may be needed.

Annotations
@Override
Exceptions
MappingException:
If configuration fails.
generateback to summary
public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException

Generate a new identifier.

Parameters
session:SharedSessionContractImplementor

The session from which the request originates

object:Object

the entity or collection (idbag) for which the id is being generated

Returns:Serializable

a new identifier

Exceptions
HibernateException:
Indicates trouble generating the identifier
initializeback to summary
public 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:SqlStringGenerationContext

A context to help generate SQL strings

registerExportablesback to summary
public default void registerExportables(Database database)

Implements org.hibernate.boot.model.relational.ExportableProducer.registerExportables.

Register database objects used by this identifier generator, e.g. sequences, tables, etc.

This method is called just once, after configure(Type, Properties, ServiceRegistry).

Parameters
database:Database

The database instance

Annotations
@Override
supportsJdbcBatchInsertsback to summary
public default boolean supportsJdbcBatchInserts()

Check if JDBC batch inserts are supported.

Returns:boolean

JDBC batch inserts are supported.