Top Description Fields Constructors Methods
org.hibernate.id

public Class MultipleHiLoPerTableGenerator

extends Object
implements PersistentIdentifierGenerator
Class Inheritance
All Implemented Interfaces
org.hibernate.id.PersistentIdentifierGenerator, org.hibernate.id.IdentifierGenerator, org.hibernate.boot.model.relational.ExportableProducer, org.hibernate.id.Configurable
Annotations
@Deprecated
Imports
java.io.Serializable, java.sql.Connection, .PreparedStatement, .ResultSet, .SQLException, .Types, java.util.Properties, org.hibernate.LockMode, .MappingException, org.hibernate.boot.model.naming.Identifier, org.hibernate.boot.model.relational.Database, .Namespace, .QualifiedName, .QualifiedNameParser, .SqlStringGenerationContext, org.hibernate.dialect.Dialect, org.hibernate.engine.jdbc.env.spi.JdbcEnvironment, org.hibernate.engine.jdbc.internal.FormatStyle, org.hibernate.engine.jdbc.spi.JdbcServices, .SqlStatementLogger, org.hibernate.engine.spi.SessionEventListenerManager, .SharedSessionContractImplementor, org.hibernate.id.enhanced.AccessCallback, .LegacyHiLoAlgorithmOptimizer, org.hibernate.internal.CoreLogging, .CoreMessageLogger, org.hibernate.internal.log.DeprecationLogger, org.hibernate.internal.util.config.ConfigurationHelper, org.hibernate.jdbc.AbstractReturningWork, .WorkExecutorVisitable, org.hibernate.mapping.Column, .PrimaryKey, .Table, org.hibernate.service.ServiceRegistry, org.hibernate.type.LongType, .StringType, .Type

Deprecated

Use org.hibernate.id.enhanced.TableGenerator instead.

A hilo IdentifierGenerator that returns a Long, constructed using a hi/lo algorithm. The hi value MUST be fetched in a separate transaction to the Session transaction so the generator must be able to obtain a new connection and commit it. Hence this implementation may not be used when the user is supplying connections. In this case a SequenceHiLoGenerator would be a better choice (where supported).

A hilo IdentifierGenerator that uses a database table to store the last generated values. A table can contains several hi values. They are distinct from each other through a key

This implementation is not compliant with a user connection

Allowed parameters (all of them are optional):

Authors
Emmanuel Bernard, Klaus Richarz.

Field Summary

Modifier and TypeField and Description
private static final String
private static final int
public static final String
private static final String
private String
private LegacyHiLoAlgorithmOptimizer
public static final String
private String
private int
private static final CoreMessageLogger
public static final String
private int
private QualifiedName
public static final String
public static final String
public static final String
private QualifiedName
private String
private Class<T>
private String
private String
private String
public static final String
private String

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
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.
protected QualifiedName
protected String
protected String
private ResultSet
private int
public synchronized Serializable
generate(final 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.
public Object
generatorKey()

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

Deprecated
Return a key unique to the underlying database objects.
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 PreparedStatement
prepareStatement(Connection connection, String sql, SqlStatementLogger statementLogger, SessionEventListenerManager statsCollector)

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_PK_COLUMNback to summary
private static final String DEFAULT_PK_COLUMN
DEFAULT_PK_LENGTHback to summary
private static final int DEFAULT_PK_LENGTH
DEFAULT_TABLEback to summary
public static final String DEFAULT_TABLE
DEFAULT_VALUE_COLUMNback to summary
private static final String DEFAULT_VALUE_COLUMN
formattedTableNameForLegacyGetterback to summary
private String formattedTableNameForLegacyGetter

Deprecated

Annotations
@Deprecated
hiloOptimizerback to summary
private LegacyHiLoAlgorithmOptimizer hiloOptimizer
ID_TABLEback to summary
public static final String ID_TABLE
insertback to summary
private String insert
keySizeback to summary
private int keySize
LOGback to summary
private static final CoreMessageLogger LOG
MAX_LOback to summary
public static final String MAX_LO
maxLoback to summary
private int maxLo
physicalTableNameback to summary
private QualifiedName physicalTableName
PK_COLUMN_NAMEback to summary
public static final String PK_COLUMN_NAME
PK_LENGTH_NAMEback to summary
public static final String PK_LENGTH_NAME
PK_VALUE_NAMEback to summary
public static final String PK_VALUE_NAME
qualifiedTableNameback to summary
private QualifiedName qualifiedTableName
queryback to summary
private String query
returnClassback to summary
private Class<T> returnClass
segmentColumnNameback to summary
private String segmentColumnName
segmentNameback to summary
private String segmentName
updateback to summary
private String update
VALUE_COLUMN_NAMEback to summary
public static final String VALUE_COLUMN_NAME
valueColumnNameback to summary
private String valueColumnName

Constructor Detail

MultipleHiLoPerTableGeneratorback to summary
public MultipleHiLoPerTableGenerator()

Method Detail

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, deprecation
Exceptions
MappingException:
If configuration fails.
determineGeneratorTableNameback to summary
protected QualifiedName determineGeneratorTableName(Properties params, JdbcEnvironment jdbcEnvironment)
determineSegmentColumnNameback to summary
protected String determineSegmentColumnName(Properties params, JdbcEnvironment jdbcEnvironment)
determineValueColumnNameback to summary
protected String determineValueColumnName(Properties params, JdbcEnvironment jdbcEnvironment)
executeQueryback to summary
private ResultSet executeQuery(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException
executeUpdateback to summary
private int executeUpdate(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException
generateback to summary
public synchronized Serializable generate(final 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

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
@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
prepareStatementback to summary
private PreparedStatement prepareStatement(Connection connection, String sql, SqlStatementLogger statementLogger, SessionEventListenerManager statsCollector) throws SQLException
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