org.hibernate.id.enhanced

Class SequenceStyleGenerator

Implemented Interfaces:
Configurable, IdentifierGenerator, PersistentIdentifierGenerator

public class SequenceStyleGenerator
extends java.lang.Object
implements PersistentIdentifierGenerator, Configurable

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:

NAMEDEFAULTDESCRIPTION
SEQUENCE_PARAMDEF_SEQUENCE_NAMEThe name of the sequence/table to use to store/retrieve values
INITIAL_PARAMDEFAULT_INITIAL_VALUEThe initial value to be stored for the given segment; the effect in terms of storage varies based on Optimizer and DatabaseStructure
INCREMENT_PARAMDEFAULT_INCREMENT_SIZEThe increment size for the underlying segment; the effect in terms of storage varies based on Optimizer and DatabaseStructure
OPT_PARAMdepends on defined increment sizeAllows explicit definition of which optimization strategy to use
FORCE_TBL_PARAMfalseAllows explicit definition of which optimization strategy to use

Configuration parameters used specifically when the underlying structure is a table:

NAMEDEFAULTDESCRIPTION
VALUE_COLUMN_PARAMDEF_VALUE_COLUMNThe name of column which holds the sequence value for the given segment
Author:
Steve Ebersole

Field Summary

static int
DEFAULT_INCREMENT_SIZE
static int
DEFAULT_INITIAL_VALUE
static String
DEF_SEQUENCE_NAME
static String
DEF_VALUE_COLUMN
static String
FORCE_TBL_PARAM
static String
INCREMENT_PARAM
static String
INITIAL_PARAM
static String
OPT_PARAM
static String
SEQUENCE_PARAM
static String
VALUE_COLUMN_PARAM

Fields inherited from interface org.hibernate.id.IdentifierGenerator

ENTITY_NAME

Fields inherited from interface org.hibernate.id.PersistentIdentifierGenerator

CATALOG, PK, SCHEMA, SQL_STATEMENT_LOGGER, TABLE, TABLES

Method Summary

void
configure(Type type, Properties params, Dialect dialect)
Configure this instance, given the value of parameters specified by the user as <param> elements.
Serializable
generate(SessionImplementor session, Object object)
Generate a new identifier.
Object
generatorKey()
DatabaseStructure
getDatabaseStructure()
Type
getIdentifierType()
Optimizer
getOptimizer()
String[]
sqlCreateStrings(Dialect dialect)
String[]
sqlDropStrings(Dialect dialect)

Field Details

DEFAULT_INCREMENT_SIZE

public static final int DEFAULT_INCREMENT_SIZE
Field Value:
1

DEFAULT_INITIAL_VALUE

public static final int DEFAULT_INITIAL_VALUE
Field Value:
1

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

Method Details

configure

public void configure(Type type,
                      Properties params,
                      Dialect dialect)
            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.
Specified by:
configure in interface Configurable
Parameters:
params - param values, keyed by parameter name

generate

public Serializable generate(SessionImplementor session,
                             Object object)
            throws HibernateException
Generate a new identifier.
Specified by:
generate in interface IdentifierGenerator
Parameters:
session -
object - the entity or toplevel collection for which the id is being generated
Returns:
a new identifier

generatorKey

public Object generatorKey()
Specified by:
generatorKey in interface PersistentIdentifierGenerator

getDatabaseStructure

public DatabaseStructure getDatabaseStructure()

getIdentifierType

public Type getIdentifierType()

getOptimizer

public Optimizer getOptimizer()

sqlCreateStrings

public String[] sqlCreateStrings(Dialect dialect)
            throws HibernateException
Specified by:
sqlCreateStrings in interface PersistentIdentifierGenerator

sqlDropStrings

public String[] sqlDropStrings(Dialect dialect)
            throws HibernateException
Specified by:
sqlDropStrings in interface PersistentIdentifierGenerator