public class SequenceStyleGenerator extends Object implements PersistentIdentifierGenerator, BulkInsertionCapableIdentifierGenerator, Configurable
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 | 
| 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 | 
|---|---|
static String | 
CONFIG_PREFER_SEQUENCE_PER_ENTITY
Used to create dedicated sequence for each entity based on the entity name. 
 | 
static 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. 
 | 
static String | 
DEF_SEQUENCE_NAME
The default value for  
SEQUENCE_PARAM, in the absence of any CONFIG_PREFER_SEQUENCE_PER_ENTITY
 setting. | 
static String | 
DEF_SEQUENCE_SUFFIX
The default value for  
CONFIG_SEQUENCE_PER_ENTITY_SUFFIX | 
static String | 
DEF_VALUE_COLUMN
The default value for  
VALUE_COLUMN_PARAM | 
static int | 
DEFAULT_INCREMENT_SIZE
The default value for  
INCREMENT_PARAM | 
static int | 
DEFAULT_INITIAL_VALUE
The default value for  
INITIAL_PARAM | 
static String | 
FORCE_TBL_PARAM
A flag to force using a table as the underlying structure rather than a sequence. 
 | 
static String | 
INCREMENT_PARAM
Indicates the increment size to use. 
 | 
static String | 
INITIAL_PARAM
Indicates the initial value to use. 
 | 
static String | 
OPT_PARAM
Indicates the optimizer to use, either naming a  
Optimizer implementation class or naming
 a StandardOptimizerDescriptor by name | 
static String | 
SEQUENCE_PARAM
Indicates the name of the sequence (or table) to use. 
 | 
static String | 
VALUE_COLUMN_PARAM
Indicates the name of the column holding the identifier values. 
 | 
CATALOG, IDENTIFIER_NORMALIZER, PK, SCHEMA, TABLE, TABLESENTITY_NAME, JPA_ENTITY_NAME| Constructor and Description | 
|---|
SequenceStyleGenerator()  | 
| Modifier and Type | Method and Description | 
|---|---|
protected DatabaseStructure | 
buildDatabaseStructure(Type type,
                      Properties params,
                      Dialect dialect,
                      boolean forceTableUse,
                      String sequenceName,
                      int initialValue,
                      int incrementSize)
Build the database structure. 
 | 
void | 
configure(Type type,
         Properties params,
         Dialect dialect)
Configure this instance, given the value of parameters
 specified by the user as <param> elements. 
 | 
protected int | 
determineAdjustedIncrementSize(String optimizationStrategy,
                              int incrementSize)
In certain cases we need to adjust the increment size based on the
 selected optimizer. 
 | 
String | 
determineBulkInsertionIdentifierGenerationSelectFragment(Dialect dialect)
Return the select expression fragment, if any, that generates the identifier values. 
 | 
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,
                     Dialect dialect)
Determine the name of the sequence (or table if this resolves to a physical table)
 to use. 
 | 
protected String | 
determineValueColumnName(Properties params,
                        Dialect dialect)
Determine the name of the column used to store the generator value in
 the db. 
 | 
Serializable | 
generate(SessionImplementor session,
        Object object)
Generate a new identifier. 
 | 
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'. 
 | 
String[] | 
sqlCreateStrings(Dialect dialect)
The SQL required to create the underlying database objects. 
 | 
String[] | 
sqlDropStrings(Dialect dialect)
The SQL required to remove the underlying database objects. 
 | 
boolean | 
supportsBulkInsertionIdentifierGeneration()
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 
 | 
public static final String SEQUENCE_PARAM
DEF_SEQUENCE_NAME,
 although CONFIG_PREFER_SEQUENCE_PER_ENTITY effects the default as well.public static final String DEF_SEQUENCE_NAME
SEQUENCE_PARAM, in the absence of any CONFIG_PREFER_SEQUENCE_PER_ENTITY
 setting.public static final String INITIAL_PARAM
DEFAULT_INITIAL_VALUEpublic static final int DEFAULT_INITIAL_VALUE
INITIAL_PARAMpublic static final String INCREMENT_PARAM
DEFAULT_INCREMENT_SIZEpublic static final int DEFAULT_INCREMENT_SIZE
INCREMENT_PARAMpublic static final String CONFIG_PREFER_SEQUENCE_PER_ENTITY
CONFIG_SEQUENCE_PER_ENTITY_SUFFIX option.public static final String CONFIG_SEQUENCE_PER_ENTITY_SUFFIX
CONFIG_PREFER_SEQUENCE_PER_ENTITY.public static final String DEF_SEQUENCE_SUFFIX
CONFIG_SEQUENCE_PER_ENTITY_SUFFIXpublic static final String OPT_PARAM
Optimizer implementation class or naming
 a StandardOptimizerDescriptor by namepublic static final String FORCE_TBL_PARAM
public static final String VALUE_COLUMN_PARAM
DEF_VALUE_COLUMNpublic static final String DEF_VALUE_COLUMN
VALUE_COLUMN_PARAMpublic DatabaseStructure getDatabaseStructure()
public Optimizer getOptimizer()
public Type getIdentifierType()
public void configure(Type type, Properties params, Dialect dialect) throws MappingException
Configurableconfigure in interface Configurableparams - param values, keyed by parameter nameMappingExceptionprotected String determineSequenceName(Properties params, Dialect dialect)
configuration.params - The params supplied in the generator config (plus some standard useful extras).dialect - The dialect in effectprotected String determineValueColumnName(Properties params, Dialect dialect)
configuration when resolving to a
 physical table.params - The params supplied in the generator config (plus some standard useful extras).dialect - The dialect in effect.protected int determineInitialValue(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(Properties params)
optimizer being used.
 
 Called during configuration.params - The params supplied in the generator config (plus some standard useful extras).protected String determineOptimizationStrategy(Properties params, int incrementSize)
configuration.params - The params supplied in the generator config (plus some standard useful extras).incrementSize - The determined increment sizeprotected int determineAdjustedIncrementSize(String optimizationStrategy, int incrementSize)
optimizationStrategy - The optimizer strategy (name)incrementSize - The determined increment sizeprotected DatabaseStructure buildDatabaseStructure(Type type, Properties params, Dialect dialect, boolean forceTableUse, String sequenceName, int initialValue, int incrementSize)
type - The Hibernate type of the identifier propertyparams - 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 Serializable generate(SessionImplementor session, Object object) throws HibernateException
IdentifierGeneratorgenerate in interface IdentifierGeneratorsession - The session from which the request originatesobject - the entity or collection (idbag) for which the id is being generatedHibernateException - Indicates trouble generating the identifierpublic Object generatorKey()
PersistentIdentifierGeneratorgeneratorKey in interface PersistentIdentifierGeneratorpublic String[] sqlCreateStrings(Dialect dialect) throws HibernateException
PersistentIdentifierGeneratorsqlCreateStrings in interface PersistentIdentifierGeneratordialect - The dialect against which to generate the create command(s)HibernateException - problem creating the create command(s)public String[] sqlDropStrings(Dialect dialect) throws HibernateException
PersistentIdentifierGeneratorsqlDropStrings in interface PersistentIdentifierGeneratordialect - The dialect against which to generate the drop command(s)HibernateException - problem creating the drop command(s)public boolean supportsBulkInsertionIdentifierGeneration()
BulkInsertionCapableIdentifierGeneratorsupportsBulkInsertionIdentifierGeneration in interface BulkInsertionCapableIdentifierGeneratortrue if bulk insertions are supported; false otherwise.public String determineBulkInsertionIdentifierGenerationSelectFragment(Dialect dialect)
BulkInsertionCapableIdentifierGeneratordetermineBulkInsertionIdentifierGenerationSelectFragment in interface BulkInsertionCapableIdentifierGeneratordialect - The dialect against which the insert will be performed.null indicates that no fragment is needed.Copyright © 2001-2015 Red Hat, Inc. All Rights Reserved.