org.hibernate.id
Class SequenceGenerator

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

public class SequenceGenerator
extends Object
implements PersistentIdentifierGenerator, Configurable

sequence

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

Mapping parameters supported: sequence, parameters.

Author:
Gavin King
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, PK, SCHEMA, SQL, TABLE, TABLES
 
Fields inherited from interface org.hibernate.id.IdentifierGenerator
ENTITY_NAME
 
Constructor Summary
SequenceGenerator()
           
 
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 obj)
          Generate a new identifier.
 Object generatorKey()
          Return a key unique to the underlying database objects.
 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.
 
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

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)
                      throws HibernateException
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
Throws:
HibernateException

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
Returns:
String[]
Throws:
HibernateException

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
Returns:
String
Throws:
HibernateException

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()