Package org.hibernate.id
Class IncrementGenerator
java.lang.Object
org.hibernate.id.IncrementGenerator
- All Implemented Interfaces:
Serializable,ExportableProducer,BeforeExecutionGenerator,Generator,Configurable,StandardGenerator,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.)
- Author:
- Gavin King, Steve Ebersole, Brett Meyer
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA parameter identifying the column holding the id.static final StringA 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 TypeMethodDescriptionvoidconfigure(Type type, Properties parameters, ServiceRegistry serviceRegistry) Configure this instance, given the value of parameters specified by the user as<param>elements.generate(SharedSessionContractImplementor session, Object object) Generate a new identifier.String[]Deprecated.Exposed for tests only.voidinitialize(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, waitMethods inherited from interface org.hibernate.generator.BeforeExecutionGenerator
generatedOnExecutionMethods inherited from interface org.hibernate.id.Configurable
createMethods inherited from interface org.hibernate.generator.Generator
allowAssignedIdentifiers, generatedOnExecution, generatesOnInsert, generatesOnUpdate, generatesSometimesMethods inherited from interface org.hibernate.id.IdentifierGenerator
generate, getEventTypes, registerExportables, supportsJdbcBatchInserts
-
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(Type type, Properties parameters, ServiceRegistry serviceRegistry) throws MappingException Description copied from interface:IdentifierGeneratorConfigure 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:
configurein interfaceConfigurable- Specified by:
configurein 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
Description copied from interface:ConfigurableInitializes 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:
initializein interfaceConfigurable- Parameters:
context- A context to help generate SQL strings
-