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 java.lang.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 java.lang.String PARAMETERS
          The parameters parameter, appended to the create sequence DDL.
static java.lang.String SEQUENCE
          The sequence parameter
 
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
SequenceGenerator()
           
 
Method Summary
 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.
 java.io.Serializable generate(SessionImplementor session, java.lang.Object obj)
          Generate a new identifier.
 java.lang.Object generatorKey()
          Return a key unique to the underlying database objects.
 java.lang.String getSequenceName()
           
 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

SEQUENCE

public static final java.lang.String SEQUENCE
The sequence parameter

See Also:
Constant Field Values

PARAMETERS

public static final java.lang.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,
                      java.util.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 java.io.Serializable generate(SessionImplementor session,
                                     java.lang.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 java.lang.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 java.lang.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)

generatorKey

public java.lang.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 java.lang.String getSequenceName()


Copyright © 2008 Hibernate.org. All Rights Reserved.