org.hibernate.id
Class SequenceGenerator

java.lang.Object
  extended by org.hibernate.id.SequenceGenerator
All Implemented Interfaces:
BulkInsertionCapableIdentifierGenerator, Configurable, IdentifierGenerator, PersistentIdentifierGenerator
Direct Known Subclasses:
SequenceHiLoGenerator, SequenceIdentityGenerator

public class SequenceGenerator
extends Object
implements PersistentIdentifierGenerator, BulkInsertionCapableIdentifierGenerator, Configurable

sequence

Generates long values using an oracle-style sequence. A higher performance algorithm is SequenceHiLoGenerator.

Mapping parameters supported: sequence, parameters.

See Also:
SequenceHiLoGenerator, TableHiLoGenerator

Field Summary
static String PARAMETERS
          The parameters parameter, appended to the create sequence DDL.
static String SEQUENCE
          The sequence parameter
 
Fields inherited from interface org.hibernate.id.PersistentIdentifierGenerator
CATALOG, IDENTIFIER_NORMALIZER, PK, SCHEMA, TABLE, TABLES
 
Fields inherited from interface org.hibernate.id.IdentifierGenerator
ENTITY_NAME, JPA_ENTITY_NAME
 
Constructor Summary
SequenceGenerator()
           
 
Method Summary
protected  IntegralDataTypeHolder buildHolder()
           
 void configure(Type type, Properties params, Dialect dialect)
          Configure this instance, given the value of parameters specified by the user as <param> elements.
 String determineBulkInsertionIdentifierGenerationSelectFragment(Dialect dialect)
          Return the select expression fragment, if any, that generates the identifier values.
 Serializable generate(SessionImplementor session, Object obj)
          Generate a new identifier.
protected  IntegralDataTypeHolder generateHolder(SessionImplementor session)
           
 Object generatorKey()
          Return a key unique to the underlying database objects.
protected  Type getIdentifierType()
           
 String getSequenceName()
           
 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

 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEQUENCE

public static final String SEQUENCE
The sequence parameter

See Also:
Constant Field Values

PARAMETERS

public static final String PARAMETERS
The parameters parameter, appended to the create sequence DDL. For example (Oracle): INCREMENT BY 1 START WITH 1 MAXVALUE 100 NOCACHE.

See Also:
Constant Field Values
Constructor Detail

SequenceGenerator

public SequenceGenerator()
Method Detail

getIdentifierType

protected Type getIdentifierType()

generatorKey

public Object generatorKey()
Description copied from interface: PersistentIdentifierGenerator
Return a key unique to the underlying database objects. Prevents us from trying to create/remove them multiple times.

Specified by:
generatorKey in interface PersistentIdentifierGenerator
Returns:
Object an identifying key for this generator

getSequenceName

public String getSequenceName()

configure

public void configure(Type type,
                      Properties params,
                      Dialect dialect)
               throws MappingException
Description copied from interface: Configurable
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
params - param values, keyed by parameter name
Throws:
MappingException

generate

public Serializable generate(SessionImplementor session,
                             Object obj)
Description copied from interface: IdentifierGenerator
Generate a new identifier.

Specified by:
generate in interface IdentifierGenerator
obj - the entity or toplevel collection for which the id is being generated
Returns:
a new identifier

generateHolder

protected IntegralDataTypeHolder generateHolder(SessionImplementor session)

buildHolder

protected IntegralDataTypeHolder buildHolder()

sqlCreateStrings

public String[] sqlCreateStrings(Dialect dialect)
                          throws HibernateException
Description copied from interface: PersistentIdentifierGenerator
The SQL required to create the underlying database objects.

Specified by:
sqlCreateStrings in interface PersistentIdentifierGenerator
Parameters:
dialect - The dialect against which to generate the create command(s)
Returns:
The create command(s)
Throws:
HibernateException - problem creating the create command(s)

sqlDropStrings

public String[] sqlDropStrings(Dialect dialect)
                        throws HibernateException
Description copied from interface: PersistentIdentifierGenerator
The SQL required to remove the underlying database objects.

Specified by:
sqlDropStrings in interface PersistentIdentifierGenerator
Parameters:
dialect - The dialect against which to generate the drop command(s)
Returns:
The drop command(s)
Throws:
HibernateException - problem creating the drop command(s)

supportsBulkInsertionIdentifierGeneration

public boolean supportsBulkInsertionIdentifierGeneration()
Description copied from interface: BulkInsertionCapableIdentifierGenerator
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

Specified by:
supportsBulkInsertionIdentifierGeneration in interface BulkInsertionCapableIdentifierGenerator
Returns:
true if bulk insertions are supported; false otherwise.

determineBulkInsertionIdentifierGenerationSelectFragment

public String determineBulkInsertionIdentifierGenerationSelectFragment(Dialect dialect)
Description copied from interface: BulkInsertionCapableIdentifierGenerator
Return the select expression fragment, if any, that generates the identifier values.

Specified by:
determineBulkInsertionIdentifierGenerationSelectFragment in interface BulkInsertionCapableIdentifierGenerator
Parameters:
dialect - The dialect against which the insert will be performed.
Returns:
The identifier value generation fragment (SQL). null indicates that no fragment is needed.


Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.