Top Description Fields Constructors Methods
org.hibernate.id

public Class SequenceGenerator

extends Object
implements PersistentIdentifierGenerator, BulkInsertionCapableIdentifierGenerator
Class Inheritance
All Implemented Interfaces
org.hibernate.id.BulkInsertionCapableIdentifierGenerator, org.hibernate.id.IdentifierGenerator, org.hibernate.boot.model.relational.ExportableProducer, org.hibernate.id.Configurable, org.hibernate.id.PersistentIdentifierGenerator
Known Direct Subclasses
org.hibernate.id.SequenceHiLoGenerator, org.hibernate.id.SequenceIdentityGenerator
Annotations
@Deprecated
Imports
java.io.Serializable, java.sql.PreparedStatement, .ResultSet, .SQLException, java.util.Properties, org.hibernate.MappingException, org.hibernate.boot.model.naming.ObjectNameNormalizer, org.hibernate.boot.model.relational.Database, .Namespace, .QualifiedName, .QualifiedNameParser, .Sequence, .SqlStringGenerationContext, org.hibernate.engine.jdbc.env.spi.JdbcEnvironment, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.internal.log.DeprecationLogger, org.hibernate.internal.util.config.ConfigurationHelper, org.hibernate.service.ServiceRegistry, org.hibernate.type.Type, org.jboss.logging.Logger

Deprecated

Use org.hibernate.id.enhanced.SequenceStyleGenerator instead

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

Field Summary

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

The parameters parameter, appended to the create sequence DDL.

private QualifiedName
public static final String
SEQUENCE

The sequence parameter

private String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected IntegralDataTypeHolder
public void
configure(Type
The id property type descriptor
type
,
Properties
param values, keyed by parameter name
params
,
ServiceRegistry
Access to service that may be needed.
serviceRegistry
)

Overrides default org.hibernate.id.IdentifierGenerator.configure.

Configure this instance, given the value of parameters specified by the user as <param> elements.
public String
determineBulkInsertionIdentifierGenerationSelectFragment(SqlStringGenerationContext
A context for SQL string generation.
context
)

Overrides default org.hibernate.id.BulkInsertionCapableIdentifierGenerator.determineBulkInsertionIdentifierGenerationSelectFragment.

Return the select expression fragment, if any, that generates the identifier values.
public Serializable
generate(SharedSessionContractImplementor
The session from which the request originates
session
,
Object
the entity or collection (idbag) for which the id is being generated
obj
)

Implements org.hibernate.id.IdentifierGenerator.generate.

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

Overrides default org.hibernate.id.PersistentIdentifierGenerator.generatorKey.

Deprecated
Return a key unique to the underlying database objects.
public String[]
getAllSqlForTests()

Deprecated Exposed for tests only.
protected Type
public QualifiedName
public String
getSequenceName()

Deprecated
public void
initialize(SqlStringGenerationContext
A context to help generate SQL strings
context
)

Overrides default org.hibernate.id.IdentifierGenerator.initialize.

Initializes this instance, in particular pre-generates SQL as necessary.
public void
registerExportables(Database
The database instance
database
)

Overrides default org.hibernate.id.IdentifierGenerator.registerExportables.

Register database objects used by this identifier generator, e.g. sequences, tables, etc.

This method is called just once, after configure(Type, Properties, ServiceRegistry).

public boolean
supportsBulkInsertionIdentifierGeneration()

Implements org.hibernate.id.BulkInsertionCapableIdentifierGenerator.supportsBulkInsertionIdentifierGeneration.

Given the configuration of this generator, is identifier generation as part of bulk insertion supported?
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

formattedSequenceNameForLegacyGetterback to summary
private String formattedSequenceNameForLegacyGetter

Deprecated

Annotations
@Deprecated
identifierTypeback to summary
private Type identifierType
LOGback to summary
private static final Logger LOG
logicalQualifiedSequenceNameback to summary
private QualifiedName logicalQualifiedSequenceName
PARAMETERSback to summary
public static final String PARAMETERS

Deprecated

No longer supported. To specify initial-value or increment use the org.hibernate.id.enhanced.SequenceStyleGenerator generator instead.

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

Annotations
@Deprecated
physicalSequenceNameback to summary
private QualifiedName physicalSequenceName
SEQUENCEback to summary
public static final String SEQUENCE

The sequence parameter

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, ServiceRegistry serviceRegistry) throws MappingException

Overrides default org.hibernate.id.IdentifierGenerator.configure.

Doc from org.hibernate.id.IdentifierGenerator.configure.

Configure this instance, given the value of parameters specified by the user as <param> elements.

This method is called just once, following instantiation, and before registerExportables(Database).

Parameters
type:Type

The id property type descriptor

params:Properties

param values, keyed by parameter name

serviceRegistry:ServiceRegistry

Access to service that may be needed.

Annotations
@Override
@SuppressWarnings:StatementWithEmptyBody
Exceptions
MappingException:
If configuration fails.
determineBulkInsertionIdentifierGenerationSelectFragmentback to summary
public String determineBulkInsertionIdentifierGenerationSelectFragment(SqlStringGenerationContext context)

Overrides default org.hibernate.id.BulkInsertionCapableIdentifierGenerator.determineBulkInsertionIdentifierGenerationSelectFragment.

Doc from org.hibernate.id.BulkInsertionCapableIdentifierGenerator.determineBulkInsertionIdentifierGenerationSelectFragment.

Return the select expression fragment, if any, that generates the identifier values.

Parameters
context:SqlStringGenerationContext

A context for SQL string generation.

Returns:String

The identifier value generation fragment (SQL). null indicates that no fragment is needed.

Annotations
@Override
generateback to summary
public Serializable generate(SharedSessionContractImplementor session, Object obj)

Implements org.hibernate.id.IdentifierGenerator.generate.

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

Generate a new identifier.

Parameters
session:SharedSessionContractImplementor

The session from which the request originates

obj:Object

the entity or collection (idbag) for which the id is being generated

Returns:Serializable

a new identifier

Annotations
@Override
generateHolderback to summary
protected IntegralDataTypeHolder generateHolder(SharedSessionContractImplementor session)
generatorKeyback to summary
public Object generatorKey()

Overrides default org.hibernate.id.PersistentIdentifierGenerator.generatorKey.

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

Deprecated

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

Annotations
@Override
@Deprecated
getAllSqlForTestsback to summary
public String[] getAllSqlForTests()

Deprecated

Exposed for tests only.

Annotations
@Deprecated
getIdentifierTypeback to summary
protected Type getIdentifierType()
getPhysicalSequenceNameback to summary
public QualifiedName getPhysicalSequenceName()
getSequenceNameback to summary
public String getSequenceName()

Deprecated

Annotations
@Deprecated
initializeback to summary
public void initialize(SqlStringGenerationContext context)

Overrides default org.hibernate.id.IdentifierGenerator.initialize.

Doc from org.hibernate.id.IdentifierGenerator.initialize.

Initializes this instance, in particular pre-generates SQL as necessary.

This method is called after registerExportables(Database), before first use.

Parameters
context:SqlStringGenerationContext

A context to help generate SQL strings

Annotations
@Override
registerExportablesback to summary
public void registerExportables(Database database)

Overrides default org.hibernate.id.IdentifierGenerator.registerExportables.

Doc from org.hibernate.id.IdentifierGenerator.registerExportables.

Register database objects used by this identifier generator, e.g. sequences, tables, etc.

This method is called just once, after configure(Type, Properties, ServiceRegistry).

Parameters
database:Database

The database instance

Annotations
@Override
supportsBulkInsertionIdentifierGenerationback to summary
public boolean supportsBulkInsertionIdentifierGeneration()

Implements org.hibernate.id.BulkInsertionCapableIdentifierGenerator.supportsBulkInsertionIdentifierGeneration.

Doc from org.hibernate.id.BulkInsertionCapableIdentifierGenerator.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

Returns:boolean

true if bulk insertions are supported; false otherwise.

Annotations
@Override