Top Description Fields Constructors Methods
org.hibernate.id

public Class IncrementGenerator

extends Object
implements IdentifierGenerator, StandardGenerator
Class Inheritance
All Implemented Interfaces
org.hibernate.id.factory.spi.StandardGenerator, org.hibernate.id.IdentifierGenerator, org.hibernate.id.Configurable, org.hibernate.boot.model.relational.ExportableProducer, org.hibernate.generator.BeforeExecutionGenerator, org.hibernate.generator.Generator, java.io.Serializable
Imports
java.sql.PreparedStatement, .ResultSet, .SQLException, java.util.ArrayList, .List, .Properties, org.hibernate.HibernateException, .MappingException, org.hibernate.boot.model.naming.ObjectNameNormalizer, org.hibernate.boot.model.relational.QualifiedTableName, .SqlStringGenerationContext, org.hibernate.dialect.Dialect, org.hibernate.engine.jdbc.env.spi.IdentifierHelper, .JdbcEnvironment, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.id.factory.spi.StandardGenerator, org.hibernate.internal.CoreLogging, .CoreMessageLogger, org.hibernate.service.ServiceRegistry, org.hibernate.type.Type

An IdentifierGenerator that returns a long, constructed by counting from the maximum primary key value obtained by querying the table or tables at startup.

This id generator is not safe unless a single VM has exclusive access to the database.

Mapping parameters supported, but not usually needed: tables, column. (The tables parameter specifies a comma-separated list of table names.)

Implementation Note

This also implements the increment generation type in hbm.xml mappings.

Authors
Gavin King, Steve Ebersole, Brett Meyer

Field Summary

Modifier and TypeField and Description
public static final String
COLUMN

A parameter identifying the column holding the id.

private String
private static final CoreMessageLogger
private List<QualifiedTableName>
private IntegralDataTypeHolder
private Class<?>
private String
public static final String
TABLES

A parameter specifying a list of tables over which the generated id should be unique.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
configure(Type
The id property type descriptor
type
,
Properties
param values, keyed by parameter name
parameters
,
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 synchronized Object
generate(SharedSessionContractImplementor
The session from which the request originates
session
,
Object
the entity or collection (idbag) for which the id is being generated
object
)

Implements org.hibernate.id.IdentifierGenerator.generate.

Generate a new identifier.
public String[]
getAllSqlForTests()

Deprecated Exposed for tests only.
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.
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

COLUMNback to summary
public static final String COLUMN

A parameter identifying the column holding the id.

columnback to summary
private String column
LOGback to summary
private static final CoreMessageLogger LOG
physicalTableNamesback to summary
private List<QualifiedTableName> physicalTableNames
previousValueHolderback to summary
private IntegralDataTypeHolder previousValueHolder
returnClassback to summary
private Class<?> returnClass
sqlback to summary
private String sql
TABLESback to summary
public static final String TABLES

A parameter specifying a list of tables over which the generated id should be unique.

Constructor Detail

IncrementGeneratorback to summary
public IncrementGenerator()

Method Detail

configureback to summary
public void configure(Type type, Properties parameters, 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

parameters:Properties

param values, keyed by parameter name

serviceRegistry:ServiceRegistry

Access to service that may be needed.

Annotations
@Override
generateback to summary
public synchronized Object generate(SharedSessionContractImplementor session, Object object) throws HibernateException

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

object:Object

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

Returns:Object

a new identifier

Annotations
@Override
Exceptions
HibernateException:
Indicates trouble generating the identifier
getAllSqlForTestsback to summary
public String[] getAllSqlForTests()

Deprecated

Exposed for tests only.

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), and before first use.

Parameters
context:SqlStringGenerationContext

A context to help generate SQL strings

Annotations
@Override
initializePreviousValueHolderback to summary
private void initializePreviousValueHolder(SharedSessionContractImplementor session)