|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hibernate.id.enhanced.SequenceStyleGenerator
public class SequenceStyleGenerator
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.
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 |
NAME | DEFAULT | DESCRIPTION |
VALUE_COLUMN_PARAM |
DEF_VALUE_COLUMN |
The name of column which holds the sequence value for the given segment |
Field Summary | |
---|---|
static java.lang.String |
DEF_SEQUENCE_NAME
|
static java.lang.String |
DEF_VALUE_COLUMN
|
static int |
DEFAULT_INCREMENT_SIZE
|
static int |
DEFAULT_INITIAL_VALUE
|
static java.lang.String |
FORCE_TBL_PARAM
|
static java.lang.String |
INCREMENT_PARAM
|
static java.lang.String |
INITIAL_PARAM
|
static java.lang.String |
OPT_PARAM
|
static java.lang.String |
SEQUENCE_PARAM
|
static java.lang.String |
VALUE_COLUMN_PARAM
|
Fields inherited from interface org.hibernate.id.PersistentIdentifierGenerator |
---|
CATALOG, PK, SCHEMA, SQL_STATEMENT_LOGGER, TABLE, TABLES |
Fields inherited from interface org.hibernate.id.IdentifierGenerator |
---|
ENTITY_NAME |
Constructor Summary | |
---|---|
SequenceStyleGenerator()
|
Method Summary | |
---|---|
protected DatabaseStructure |
buildDatabaseStructure(java.util.Properties params,
Dialect dialect,
boolean forceTableUse,
java.lang.String sequenceName,
int initialValue,
int incrementSize)
Build the database structure. |
void |
configure(Type type,
java.util.Properties params,
Dialect dialect)
Configure this instance, given the value of parameters specified by the user as <param> elements. |
protected int |
determineAdjustedIncrementSize(java.lang.String optimizationStrategy,
int incrementSize)
In certain cases we need to adjust the increment size based on the selected optimizer. |
protected int |
determineIncrementSize(java.util.Properties params)
Determine the increment size to be applied. |
protected int |
determineInitialValue(java.util.Properties params)
Determine the initial sequence value to use. |
protected java.lang.String |
determineOptimizationStrategy(java.util.Properties params,
int incrementSize)
Determine the optimizer to use. |
protected java.lang.String |
determineSequenceName(java.util.Properties params)
Determine the name of the sequence (or table if this resolves to a physical table) to use. |
protected java.lang.String |
determineValueColumnName(java.util.Properties params)
Determine the name of the column used to store the generator value in the db. |
java.io.Serializable |
generate(SessionImplementor session,
java.lang.Object object)
Generate a new identifier. |
java.lang.Object |
generatorKey()
Return a key unique to the underlying database objects. |
DatabaseStructure |
getDatabaseStructure()
Getter for property 'databaseStructure'. |
Type |
getIdentifierType()
Getter for property 'identifierType'. |
Optimizer |
getOptimizer()
Getter for property 'optimizer'. |
java.lang.String[] |
sqlCreateStrings(Dialect dialect)
The SQL required to create the underlying database objects. |
java.lang.String[] |
sqlDropStrings(Dialect dialect)
The SQL required to remove the underlying database objects. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String SEQUENCE_PARAM
public static final java.lang.String DEF_SEQUENCE_NAME
public static final java.lang.String INITIAL_PARAM
public static final int DEFAULT_INITIAL_VALUE
public static final java.lang.String INCREMENT_PARAM
public static final int DEFAULT_INCREMENT_SIZE
public static final java.lang.String OPT_PARAM
public static final java.lang.String FORCE_TBL_PARAM
public static final java.lang.String VALUE_COLUMN_PARAM
public static final java.lang.String DEF_VALUE_COLUMN
Constructor Detail |
---|
public SequenceStyleGenerator()
Method Detail |
---|
public DatabaseStructure getDatabaseStructure()
public Optimizer getOptimizer()
public Type getIdentifierType()
public void configure(Type type, java.util.Properties params, Dialect dialect) throws MappingException
configure
in interface Configurable
params
- param values, keyed by parameter name
MappingException
protected java.lang.String determineSequenceName(java.util.Properties params)
configuration
.
params
- The params supplied in the generator config (plus some standard useful extras).
protected java.lang.String determineValueColumnName(java.util.Properties params)
configuration
when resolving to a
physical table.
params
- The params supplied in the generator config (plus some standard useful extras).
protected int determineInitialValue(java.util.Properties params)
database structure
(i.e. sequence/table).
Called during configuration
.
params
- The params supplied in the generator config (plus some standard useful extras).
protected int determineIncrementSize(java.util.Properties params)
optimizer
being used.
Called during configuration
.
params
- The params supplied in the generator config (plus some standard useful extras).
protected java.lang.String determineOptimizationStrategy(java.util.Properties params, int incrementSize)
configuration
.
params
- The params supplied in the generator config (plus some standard useful extras).incrementSize
- The determined increment size
protected int determineAdjustedIncrementSize(java.lang.String optimizationStrategy, int incrementSize)
optimizationStrategy
- The optimizer strategy (name)incrementSize
- The determined increment size
protected DatabaseStructure buildDatabaseStructure(java.util.Properties params, Dialect dialect, boolean forceTableUse, java.lang.String sequenceName, int initialValue, int incrementSize)
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).
public java.io.Serializable generate(SessionImplementor session, java.lang.Object object) throws HibernateException
generate
in interface IdentifierGenerator
object
- the entity or toplevel collection for which the id is being generated
HibernateException
public java.lang.Object generatorKey()
generatorKey
in interface PersistentIdentifierGenerator
public java.lang.String[] sqlCreateStrings(Dialect dialect) throws HibernateException
sqlCreateStrings
in interface PersistentIdentifierGenerator
dialect
- The dialect against which to generate the create command(s)
HibernateException
- problem creating the create command(s)public java.lang.String[] sqlDropStrings(Dialect dialect) throws HibernateException
sqlDropStrings
in interface PersistentIdentifierGenerator
dialect
- The dialect against which to generate the drop command(s)
HibernateException
- problem creating the drop command(s)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |