## org.hibernate.id
Class SequenceGenerator

    java.lang.Object
      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, IDENTIFIER_NORMALIZER, PK, SCHEMA, SQL_STATEMENT_LOGGER, TABLE, TABLES`

Fields inherited from interface org.hibernate.id.IdentifierGenerator
`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.
`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.

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

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

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

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