Top Description Fields Constructors Methods
org.hibernate.id

public Class SequenceGenerator

extends Object
implements PersistentIdentifierGenerator, Configurable
Class Inheritance
All Implemented Interfaces
org.hibernate.id.Configurable, org.hibernate.id.PersistentIdentifierGenerator, org.hibernate.id.IdentifierGenerator
Known Direct Subclasses
org.hibernate.id.SequenceHiLoGenerator, org.hibernate.id.SequenceIdentityGenerator
Imports
java.io.Serializable, java.sql.PreparedStatement, .ResultSet, .SQLException, java.util.Properties, org.slf4j.Logger, .LoggerFactory, org.hibernate.HibernateException, .MappingException, org.hibernate.cfg.ObjectNameNormalizer, org.hibernate.exception.JDBCExceptionHelper, org.hibernate.dialect.Dialect, org.hibernate.engine.SessionImplementor, org.hibernate.mapping.Table, org.hibernate.type.Type, org.hibernate.util.PropertiesHelper

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

Modifier and TypeField and Description
private Type
private static final Logger
public static final String
PARAMETERS

The parameters parameter, appended to the create sequence DDL.

private String
public static final String
SEQUENCE

The sequence parameter

private String
private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected IntegralDataTypeHolder
public void
configure(Type type, Properties
param values, keyed by parameter name
params
,
Dialect dialect)

Implements org.hibernate.id.Configurable.configure.

Configure this instance, given the value of parameters specified by the user as <param> elements.
public Serializable
generate(SessionImplementor session, Object
the entity or toplevel collection for which the id is being generated
obj
)

Implements org.hibernate.id.IdentifierGenerator.generate.

Generate a new identifier.
protected IntegralDataTypeHolder
public Object
generatorKey()

Implements org.hibernate.id.PersistentIdentifierGenerator.generatorKey.

Return a key unique to the underlying database objects.
protected Type
public String
public String[]
sqlCreateStrings(Dialect
The dialect against which to generate the create command(s)
dialect
)

Implements org.hibernate.id.PersistentIdentifierGenerator.sqlCreateStrings.

The SQL required to create the underlying database objects.
public String[]
sqlDropStrings(Dialect
The dialect against which to generate the drop command(s)
dialect
)

Implements org.hibernate.id.PersistentIdentifierGenerator.sqlDropStrings.

The SQL required to remove the underlying database objects.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

identifierTypeback to summary
private Type identifierType
logback to summary
private static final Logger log
PARAMETERSback to summary
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.

parametersback to summary
private String parameters
SEQUENCEback to summary
public static final String SEQUENCE

The sequence parameter

sequenceNameback to summary
private String sequenceName
sqlback to summary
private String sql

Constructor Detail

SequenceGeneratorback to summary
public SequenceGenerator()

Method Detail

buildHolderback to summary
protected IntegralDataTypeHolder buildHolder()
configureback to summary
public void configure(Type type, Properties params, Dialect dialect) throws MappingException

Implements org.hibernate.id.Configurable.configure.

Doc from org.hibernate.id.Configurable.configure.

Configure this instance, given the value of parameters specified by the user as <param> elements. This method is called just once, following instantiation.

Parameters
params:Properties

param values, keyed by parameter name

generateback to summary
public Serializable generate(SessionImplementor session, Object obj)

Implements org.hibernate.id.IdentifierGenerator.generate.

Doc from org.hibernate.id.IdentifierGenerator.generate.

Generate a new identifier.

Parameters
obj:Object

the entity or toplevel collection for which the id is being generated

Returns:Serializable

a new identifier

generateHolderback to summary
protected IntegralDataTypeHolder generateHolder(SessionImplementor session)
generatorKeyback to summary
public Object generatorKey()

Implements org.hibernate.id.PersistentIdentifierGenerator.generatorKey.

Doc from org.hibernate.id.PersistentIdentifierGenerator.generatorKey.

Return a key unique to the underlying database objects. Prevents us from trying to create/remove them multiple times.

Returns:Object

Object an identifying key for this generator

getIdentifierTypeback to summary
protected Type getIdentifierType()
getSequenceNameback to summary
public String getSequenceName()
sqlCreateStringsback to summary
public String[] sqlCreateStrings(Dialect dialect) throws HibernateException

Implements org.hibernate.id.PersistentIdentifierGenerator.sqlCreateStrings.

Doc from org.hibernate.id.PersistentIdentifierGenerator.sqlCreateStrings.

The SQL required to create the underlying database objects.

Parameters
dialect:Dialect

The dialect against which to generate the create command(s)

Returns:String[]

The create command(s)

Exceptions
HibernateException:
problem creating the create command(s)
sqlDropStringsback to summary
public String[] sqlDropStrings(Dialect dialect) throws HibernateException

Implements org.hibernate.id.PersistentIdentifierGenerator.sqlDropStrings.

Doc from org.hibernate.id.PersistentIdentifierGenerator.sqlDropStrings.

The SQL required to remove the underlying database objects.

Parameters
dialect:Dialect

The dialect against which to generate the drop command(s)

Returns:String[]

The drop command(s)

Exceptions
HibernateException:
problem creating the drop command(s)