org.hibernate.id.enhanced
Class SequenceStyleGenerator
java.lang.Object
org.hibernate.id.enhanced.SequenceStyleGenerator
- Configurable, IdentifierGenerator, PersistentIdentifierGenerator
public class SequenceStyleGenerator
extends java.lang.Object
Generates identifier values based on an sequence-style database structure.
Variations range from actually using a sequence to using a table to mimic
a sequence. These variations are encapsulated by the
DatabaseStructure
interface internally.
General configuration parameters:
Configuration parameters used specifically when the underlying structure is a table:
protected DatabaseStructure | buildDatabaseStructure(Properties params, Dialect dialect, boolean forceTableUse, String sequenceName, int initialValue, int incrementSize) - Build the database structure.
|
void | configure(Type type, Properties params, Dialect dialect) -
|
protected int | determineAdjustedIncrementSize(String optimizationStrategy, int incrementSize) - In certain cases we need to adjust the increment size based on the
selected optimizer.
|
protected int | determineIncrementSize(Properties params) - Determine the increment size to be applied.
|
protected int | determineInitialValue(Properties params) - Determine the initial sequence value to use.
|
protected String | determineOptimizationStrategy(Properties params, int incrementSize) - Determine the optimizer to use.
|
protected String | determineSequenceName(Properties params) - Determine the name of the sequence (or table if this resolves to a physical table)
to use.
|
protected String | determineValueColumnName(Properties params) - Determine the name of the column used to store the generator value in
the db.
|
Serializable | generate(SessionImplementor session, Object object) -
|
Object | generatorKey() -
|
DatabaseStructure | getDatabaseStructure() - Getter for property 'databaseStructure'.
|
Type | getIdentifierType() - Getter for property 'identifierType'.
|
Optimizer | getOptimizer() - Getter for property 'optimizer'.
|
String[] | sqlCreateStrings(Dialect dialect) -
|
String[] | sqlDropStrings(Dialect dialect) -
|
DEFAULT_INCREMENT_SIZE
public static final int DEFAULT_INCREMENT_SIZE
DEFAULT_INITIAL_VALUE
public static final int DEFAULT_INITIAL_VALUE
DEF_SEQUENCE_NAME
public static final String DEF_SEQUENCE_NAME
DEF_VALUE_COLUMN
public static final String DEF_VALUE_COLUMN
FORCE_TBL_PARAM
public static final String FORCE_TBL_PARAM
INCREMENT_PARAM
public static final String INCREMENT_PARAM
INITIAL_PARAM
public static final String INITIAL_PARAM
OPT_PARAM
public static final String OPT_PARAM
SEQUENCE_PARAM
public static final String SEQUENCE_PARAM
VALUE_COLUMN_PARAM
public static final String VALUE_COLUMN_PARAM
buildDatabaseStructure
protected DatabaseStructure buildDatabaseStructure(Properties params,
Dialect dialect,
boolean forceTableUse,
String sequenceName,
int initialValue,
int incrementSize)
Build the database structure.
params
- The params supplied in the generator config (plus some standard useful extras).dialect
- The dialect being used.forceTableUse
- Should a table be used even if the dialect supports sequences?sequenceName
- The name to use for the sequence or table.initialValue
- The initial value.incrementSize
- the increment size to use (after any adjustments).
- The db structure representation
determineAdjustedIncrementSize
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.
- The adjusted increment size.
determineIncrementSize
protected int determineIncrementSize(Properties params)
Determine the increment size to be applied. The exact implications of
this value depends on the
optimizer
being used.
Called during
configuration
.
params
- The params supplied in the generator config (plus some standard useful extras).
determineInitialValue
protected int determineInitialValue(Properties params)
Determine the initial sequence value to use. This value is used when
initializing the
database structure
(i.e. sequence/table).
Called during
configuration
.
params
- The params supplied in the generator config (plus some standard useful extras).
determineOptimizationStrategy
protected String determineOptimizationStrategy(Properties params,
int incrementSize)
params
- The params supplied in the generator config (plus some standard useful extras).incrementSize
- The determined increment size
- The optimizer strategy (name)
determineSequenceName
protected String determineSequenceName(Properties params)
Determine the name of the sequence (or table if this resolves to a physical table)
to use.
Called during
configuration
.
params
- The params supplied in the generator config (plus some standard useful extras).
determineValueColumnName
protected String determineValueColumnName(Properties params)
Determine the name of the column used to store the generator value in
the db.
Called during
configuration
when resolving to a
physical table.
params
- The params supplied in the generator config (plus some standard useful extras).
getDatabaseStructure
public DatabaseStructure getDatabaseStructure()
Getter for property 'databaseStructure'.
- Value for property 'databaseStructure'.
getIdentifierType
public Type getIdentifierType()
Getter for property 'identifierType'.
- Value for property 'identifierType'.
getOptimizer
public Optimizer getOptimizer()
Getter for property 'optimizer'.
- Value for property 'optimizer'.