Package org.hibernate.id
Class IncrementGenerator
- java.lang.Object
-
- org.hibernate.id.IncrementGenerator
-
- All Implemented Interfaces:
Serializable
,ExportableProducer
,BeforeExecutionGenerator
,Generator
,Configurable
,StandardGenerator
,IdentifierGenerator
public class IncrementGenerator extends Object implements IdentifierGenerator, StandardGenerator
AnIdentifierGenerator
that returns along
, 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.)
- See Also:
- Serialized Form
- Implementation Note:
- This also implements the
increment
generation type inhbm.xml
mappings.
-
-
Field Summary
Fields Modifier and Type Field Description static String
COLUMN
A parameter identifying the column holding the id.static String
TABLES
A parameter specifying a list of tables over which the generated id should be unique.-
Fields inherited from interface org.hibernate.id.IdentifierGenerator
CONTRIBUTOR_NAME, ENTITY_NAME, GENERATOR_NAME, JPA_ENTITY_NAME
-
-
Constructor Summary
Constructors Constructor Description IncrementGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
configure(Type type, Properties parameters, ServiceRegistry serviceRegistry)
Configure this instance, given the value of parameters specified by the user as<param>
elements.Object
generate(SharedSessionContractImplementor session, Object object)
Generate a new identifier.String[]
getAllSqlForTests()
Deprecated.Exposed for tests only.void
initialize(SqlStringGenerationContext context)
Initializes this instance, pre-generating SQL if necessary.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.generator.BeforeExecutionGenerator
generatedOnExecution
-
Methods inherited from interface org.hibernate.id.Configurable
create
-
Methods inherited from interface org.hibernate.generator.Generator
allowAssignedIdentifiers, generatedOnExecution, generatesOnInsert, generatesOnUpdate, generatesSometimes
-
Methods inherited from interface org.hibernate.id.IdentifierGenerator
generate, getEventTypes, registerExportables, supportsJdbcBatchInserts
-
-
-
-
Field Detail
-
COLUMN
public static final String COLUMN
A parameter identifying the column holding the id.- See Also:
- Constant Field Values
-
TABLES
public static final String TABLES
A parameter specifying a list of tables over which the generated id should be unique.- See Also:
- Constant Field Values
-
-
Method Detail
-
getAllSqlForTests
@Deprecated public String[] getAllSqlForTests()
Deprecated.Exposed for tests only.
-
generate
public Object generate(SharedSessionContractImplementor session, Object object) throws HibernateException
Description copied from interface:IdentifierGenerator
Generate a new identifier.- Specified by:
generate
in interfaceIdentifierGenerator
- Parameters:
session
- The session from which the request originatesobject
- the entity or collection (idbag) for which the id is being generated- Returns:
- a new identifier
- Throws:
HibernateException
- Indicates trouble generating the identifier
-
configure
public void configure(Type type, Properties parameters, ServiceRegistry serviceRegistry) throws MappingException
Description copied from interface:IdentifierGenerator
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
IdentifierGenerator.registerExportables(Database)
.- Specified by:
configure
in interfaceConfigurable
- Specified by:
configure
in interfaceIdentifierGenerator
- Parameters:
type
- The id property type descriptorparameters
- param values, keyed by parameter nameserviceRegistry
- Access to service that may be needed.- Throws:
MappingException
- If configuration fails.
-
initialize
public void initialize(SqlStringGenerationContext context)
Description copied from interface:Configurable
Initializes this instance, pre-generating SQL if necessary.If this instance also implements
ExportableProducer
, then this method is always called afterExportableProducer.registerExportables(Database)
, and before first use.- Specified by:
initialize
in interfaceConfigurable
- Parameters:
context
- A context to help generate SQL strings
-
-