Package org.hibernate.id
Class IncrementGenerator
java.lang.Object
org.hibernate.id.IncrementGenerator
- All Implemented Interfaces:
Serializable
,ExportableProducer
,BeforeExecutionGenerator
,Generator
,Configurable
,IdentifierGenerator
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.)
- See Also:
- Implementation Note:
- This also implements the
increment
generation type inhbm.xml
mappings.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
A parameter identifying the column holding the id.static final String
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
configure
(GeneratorCreationContext creationContext, Properties parameters) Configure this instance, given the value of parameters specified by the user as XML<param>
elements and@Parameter
annotations.generate
(SharedSessionContractImplementor session, Object object) Generate a new identifier.String[]
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.generator.Generator
allowAssignedIdentifiers, allowMutation, generatedBeforeExecution, generatedOnExecution, generatesOnInsert, generatesOnUpdate, generatesSometimes
Methods inherited from interface org.hibernate.id.IdentifierGenerator
configure, generate, getEventTypes, registerExportables
-
Field Details
-
COLUMN
A parameter identifying the column holding the id.- See Also:
-
TABLES
A parameter specifying a list of tables over which the generated id should be unique.- See Also:
-
-
Constructor Details
-
IncrementGenerator
public IncrementGenerator()
-
-
Method Details
-
getAllSqlForTests
Deprecated.Exposed for tests only. -
configure
public void configure(GeneratorCreationContext creationContext, Properties parameters) throws MappingException Description copied from interface:Configurable
Configure this instance, given the value of parameters specified by the user as XML<param>
elements and@Parameter
annotations.This method is called just once, following instantiation. If this instance also implements
ExportableProducer
, then this method is always called beforeExportableProducer.registerExportables(Database)
,- Specified by:
configure
in interfaceConfigurable
- Parameters:
creationContext
- Access to the generator creation contextparameters
- param values, keyed by parameter name- Throws:
MappingException
- when there's something wrong with the given parameters
-
initialize
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
-