Deprecated
as a consequence of PersistentIdentifierGenerator and BulkInsertionCapableIdentifierGenerator being deprecated. See corresponding docs for further information.
DatabaseStructure
interface internally.Note
that by default we utilize a single database sequence for all
generators. The configuration parameter CONFIG_PREFER_SEQUENCE_PER_ENTITY
can be used to create dedicated sequence for each entity based on its name.
Sequence suffix can be controlled with CONFIG_SEQUENCE_PER_ENTITY_SUFFIX
option.
General configuration parameters:
| NAME | DEFAULT | DESCRIPTION |
SEQUENCE_PARAM |
DEF_SEQUENCE_NAME |
The name of the sequence/table to use to store/retrieve values |
INITIAL_PARAM |
DEFAULT_INITIAL_VALUE |
The initial value to be stored for the given segment; the effect in terms of storage varies based on Optimizer and DatabaseStructure |
INCREMENT_PARAM |
DEFAULT_INCREMENT_SIZE |
The increment size for the underlying segment; the effect in terms of storage varies based on Optimizer and DatabaseStructure |
OPT_PARAM |
depends on defined increment size | Allows explicit definition of which optimization strategy to use |
FORCE_TBL_PARAM |
false | Allows explicit definition of which optimization strategy to use |
Configuration parameters used specifically when the underlying structure is a table:
| NAME | DEFAULT | DESCRIPTION |
VALUE_COLUMN_PARAM |
DEF_VALUE_COLUMN |
The name of column which holds the sequence value for the given segment |
| Modifier and Type | Field and Description |
|---|---|
| public static final String | CONFIG_PREFER_SEQUENCE_PER_ENTITY
Used to create dedicated sequence for each entity based on the entity name. |
| public static final String | CONFIG_SEQUENCE_PER_ENTITY_SUFFIX
Indicates the suffix to use in naming the identifier sequence/table name, by appending the suffix to the name of the entity. |
| private DatabaseStructure | |
| public static final String | DEF_SEQUENCE_NAME
The default value for |
| public static final String | DEF_SEQUENCE_SUFFIX
The default value for |
| public static final String | DEF_VALUE_COLUMN
The default value for |
| public static final int | DEFAULT_INCREMENT_SIZE
The default value for |
| public static final int | DEFAULT_INITIAL_VALUE
The default value for |
| public static final String | FORCE_TBL_PARAM
A flag to force using a table as the underlying structure rather than a sequence. |
| private Type | |
| public static final String | INCREMENT_PARAM
Indicates the increment size to use. |
| public static final String | INITIAL_PARAM
Indicates the initial value to use. |
| private static final CoreMessageLogger | |
| public static final String | OPT_PARAM
Indicates the optimizer to use, either naming a |
| private Optimizer | |
| public static final String | SEQUENCE_PARAM
Indicates the name of the sequence (or table) to use. |
| public static final String | VALUE_COLUMN_PARAM
Indicates the name of the column holding the identifier values. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected DatabaseStructure | Returns: An abstraction for the actual database structure in use (table vs. sequence).The Hibernate type of the identifier property type, Properties The params supplied in the generator config (plus some standard useful extras). params, JdbcEnvironment The JDBC environment in which the sequence will be used. jdbcEnvironment, boolean Should a table be used even if the dialect supports sequences? forceTableUse, QualifiedName The name to use for the sequence or table. sequenceName, int The initial value. initialValue, int the increment size to use (after any adjustments). incrementSize)Build the database structure. |
| protected DatabaseStructure | buildSequenceStructure(Type type, Properties params, JdbcEnvironment jdbcEnvironment, QualifiedName sequenceName, int initialValue, int incrementSize)
|
| protected DatabaseStructure | buildTableStructure(Type type, Properties params, JdbcEnvironment jdbcEnvironment, QualifiedName sequenceName, int initialValue, int incrementSize)
|
| public 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)Overrides default org. |
| protected int | Returns: The adjusted increment size.The optimizer strategy (name) optimizationStrategy, int incrementSize)In certain cases we need to adjust the increment size based on the selected optimizer. |
| public String | determineBulkInsertionIdentifierGenerationSelectFragment(SqlStringGenerationContext
A context for SQL string generation. context)Overrides default org. |
| protected int | Returns: The increment sizeThe params supplied in the generator config (plus some standard useful extras). params)Determine the increment size to be applied. |
| protected int | Returns: The initial valueThe params supplied in the generator config (plus some standard useful extras). params)Determine the initial sequence value to use. |
| protected String | Returns: The optimizer strategy (name)The params supplied in the generator config (plus some standard useful extras). params, int incrementSize)Determine the optimizer to use. |
| protected QualifiedName | Returns: The sequence nameThe params supplied in the generator config (plus some standard useful extras). params, Dialect The dialect in effect dialect, JdbcEnvironment The JdbcEnvironment jdbcEnv, ServiceRegistry serviceRegistry)Determine the name of the sequence (or table if this resolves to a physical table) to use. |
| protected Identifier | Returns: The value column nameThe params supplied in the generator config (plus some standard useful extras). params, JdbcEnvironment The JDBC environment jdbcEnvironment)Determine the name of the column used to store the generator value in the db. |
| public Serializable | generate(SharedSessionContractImplementor
The session from which the request originates session, Object the entity or collection (idbag) for which the id is being generated object)Implements org. |
| public Object | generatorKey()
Overrides default org.
Deprecated
Return a key unique to the underlying database objects.
|
| public DatabaseStructure | Returns: Value for property 'databaseStructure'.Getter for property 'databaseStructure'. |
| public Type | Returns: Value for property 'identifierType'.Getter for property 'identifierType'. |
| public Optimizer | |
| private Long | Returns: sequence increment valuethe current JdbcEnvironment jdbcEnvironment, String sequence name sequenceName)Get the database sequence increment value from the associated |
| public void | initialize(SqlStringGenerationContext
A context to help generate SQL strings context)Overrides default org. |
| protected boolean | |
| public void | registerExportables(Database
The database instance database)Overrides default org.
This method is called just once, after |
| public boolean | supportsBulkInsertionIdentifierGeneration()
Implements org. |
| CONFIG_PREFER_SEQUENCE_PER_ENTITY | back to summary |
|---|---|
| public static final String CONFIG_PREFER_SEQUENCE_PER_ENTITY Used to create dedicated sequence for each entity based on the entity name. Sequence suffix can be
controlled with
| |
| CONFIG_SEQUENCE_PER_ENTITY_SUFFIX | back to summary |
|---|---|
| public static final String CONFIG_SEQUENCE_PER_ENTITY_SUFFIX Indicates the suffix to use in naming the identifier sequence/table name, by appending the suffix to
the name of the entity. Used in conjunction with
| |
| databaseStructure | back to summary |
|---|---|
| private DatabaseStructure databaseStructure | |
| DEF_SEQUENCE_NAME | back to summary |
|---|---|
| public static final String DEF_SEQUENCE_NAME The default value for | |
| DEF_SEQUENCE_SUFFIX | back to summary |
|---|---|
| public static final String DEF_SEQUENCE_SUFFIX The default value for | |
| DEF_VALUE_COLUMN | back to summary |
|---|---|
| public static final String DEF_VALUE_COLUMN The default value for
| |
| DEFAULT_INCREMENT_SIZE | back to summary |
|---|---|
| public static final int DEFAULT_INCREMENT_SIZE The default value for | |
| DEFAULT_INITIAL_VALUE | back to summary |
|---|---|
| public static final int DEFAULT_INITIAL_VALUE The default value for | |
| FORCE_TBL_PARAM | back to summary |
|---|---|
| public static final String FORCE_TBL_PARAM A flag to force using a table as the underlying structure rather than a sequence. | |
| identifierType | back to summary |
|---|---|
| private Type identifierType | |
| INCREMENT_PARAM | back to summary |
|---|---|
| public static final String INCREMENT_PARAM Indicates the increment size to use. The default value is | |
| INITIAL_PARAM | back to summary |
|---|---|
| public static final String INITIAL_PARAM Indicates the initial value to use. The default value is | |
| LOG | back to summary |
|---|---|
| private static final CoreMessageLogger LOG | |
| OPT_PARAM | back to summary |
|---|---|
| public static final String OPT_PARAM Indicates the optimizer to use, either naming a | |
| optimizer | back to summary |
|---|---|
| private Optimizer optimizer | |
| SEQUENCE_PARAM | back to summary |
|---|---|
| public static final String SEQUENCE_PARAM Indicates the name of the sequence (or table) to use. The default value is | |
| VALUE_COLUMN_PARAM | back to summary |
|---|---|
| public static final String VALUE_COLUMN_PARAM Indicates the name of the column holding the identifier values. The default value is
| |
| SequenceStyleGenerator | back to summary |
|---|---|
| public SequenceStyleGenerator() | |
| buildDatabaseStructure | back to summary |
|---|---|
| protected DatabaseStructure buildDatabaseStructure(Type type, Properties params, JdbcEnvironment jdbcEnvironment, boolean forceTableUse, QualifiedName sequenceName, int initialValue, int incrementSize) Build the database structure.
| |
| buildSequenceStructure | back to summary |
|---|---|
| protected DatabaseStructure buildSequenceStructure(Type type, Properties params, JdbcEnvironment jdbcEnvironment, QualifiedName sequenceName, int initialValue, int incrementSize) | |
| buildTableStructure | back to summary |
|---|---|
protected DatabaseStructure buildTableStructure(Type type, Properties params, JdbcEnvironment jdbcEnvironment, QualifiedName sequenceName, int initialValue, int incrementSize)
| |
| configure | back to summary |
|---|---|
| public void configure(Type type, Properties params, ServiceRegistry serviceRegistry) throws MappingException Overrides default org. Doc from org. 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
| |
| determineAdjustedIncrementSize | back to summary |
|---|---|
| protected int determineAdjustedIncrementSize(String optimizationStrategy, int incrementSize) In certain cases we need to adjust the increment size based on the selected optimizer. This is the hook to achieve that.
| |
| determineBulkInsertionIdentifierGenerationSelectFragment | back to summary |
|---|---|
| public String determineBulkInsertionIdentifierGenerationSelectFragment(SqlStringGenerationContext context) Overrides default org. Return the select expression fragment, if any, that generates the identifier values.
| |
| determineIncrementSize | back to summary |
|---|---|
| protected int determineIncrementSize(Properties params) Determine the increment size to be applied. The exact implications of
this value depends on the
Called during
| |
| determineInitialValue | back to summary |
|---|---|
| protected int determineInitialValue(Properties params) Determine the initial sequence value to use. This value is used when
initializing the
Called during
| |
| determineOptimizationStrategy | back to summary |
|---|---|
| protected String determineOptimizationStrategy(Properties params, int incrementSize) Determine the optimizer to use.
Called during
| |
| determineSequenceName | back to summary |
|---|---|
| protected QualifiedName determineSequenceName(Properties params, Dialect dialect, JdbcEnvironment jdbcEnv, ServiceRegistry serviceRegistry) Determine the name of the sequence (or table if this resolves to a physical table) to use.
Called during
| |
| determineValueColumnName | back to summary |
|---|---|
| protected Identifier determineValueColumnName(Properties params, JdbcEnvironment jdbcEnvironment) Determine the name of the column used to store the generator value in the db.
Called during
| |
| generate | back to summary |
|---|---|
| public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException Implements org. Doc from org. Generate a new identifier.
| |
| generatorKey | back to summary |
|---|---|
| public Object generatorKey() Overrides default org. Doc from org. Deprecated
Return a key unique to the underlying database objects. Prevents us from trying to create/remove them multiple times.
| |
| getDatabaseStructure | back to summary |
|---|---|
| public DatabaseStructure getDatabaseStructure() Getter for property 'databaseStructure'.
| |
| getIdentifierType | back to summary |
|---|---|
| public Type getIdentifierType() Getter for property 'identifierType'.
| |
| getOptimizer | back to summary |
|---|---|
| public Optimizer getOptimizer() Getter for property 'optimizer'.
| |
| getSequenceIncrementValue | back to summary |
|---|---|
| private Long getSequenceIncrementValue(JdbcEnvironment jdbcEnvironment, String sequenceName) Get the database sequence increment value from the associated
| |
| initialize | back to summary |
|---|---|
| public void initialize(SqlStringGenerationContext context) Overrides default org. Doc from org. Initializes this instance, in particular pre-generates SQL as necessary.
This method is called after
| |
| isPhysicalSequence | back to summary |
|---|---|
| protected boolean isPhysicalSequence(JdbcEnvironment jdbcEnvironment, boolean forceTableUse) | |
| registerExportables | back to summary |
|---|---|
| public void registerExportables(Database database) Overrides default org. Doc from org. Register database objects used by this identifier generator, e.g. sequences, tables, etc.
This method is called just once, after | |
| supportsBulkInsertionIdentifierGeneration | back to summary |
|---|---|
| public boolean supportsBulkInsertionIdentifierGeneration() Implements org. Doc from org. Given the configuration of this generator, is identifier generation as part of bulk insertion supported? IMPL NOTE : Mainly here to allow stuff like SequenceStyleGenerator which *can* support this based on configuration
| |