public class ResettableTableHiLoGenerator
extends org.hibernate.id.enhanced.SequenceStyleGenerator
IdentifierGenerator
which is compatible with Hibernate 5.2.
hiloNote : This class is copied as it is from hibernate atlassian-hibernate5.2-extras (Except a couple of minor changes to replace public synchronization with a private lock. Refactor to make it unit testable)
An 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).
Mapping parameters supported: table, column, max_lo
Modifier and Type | Field and Description |
---|---|
static String |
MAX_LO
The max_lo parameter
|
CONFIG_PREFER_SEQUENCE_PER_ENTITY, CONFIG_SEQUENCE_PER_ENTITY_SUFFIX, DEF_SEQUENCE_NAME, DEF_SEQUENCE_SUFFIX, DEF_VALUE_COLUMN, DEFAULT_INCREMENT_SIZE, DEFAULT_INITIAL_VALUE, FORCE_TBL_PARAM, INCREMENT_PARAM, INITIAL_PARAM, OPT_PARAM, SEQUENCE_PARAM, VALUE_COLUMN_PARAM
Constructor and Description |
---|
ResettableTableHiLoGenerator() |
Modifier and Type | Method and Description |
---|---|
void |
configure(org.hibernate.type.Type type,
Properties params,
org.hibernate.service.ServiceRegistry serviceRegistry) |
Serializable |
generate(org.hibernate.engine.spi.SharedSessionContractImplementor session,
Object obj) |
int |
getMaxLo()
Get the max_lo value, so that we can calculate a valid value for the next_hi DB value,
given the ids already allocated in the database.
|
void |
reset()
Set the lo value to more than maxLo to force a reset of the hi value.
|
String[] |
sqlCreateStrings(org.hibernate.dialect.Dialect dialect) |
buildDatabaseStructure, buildSequenceStructure, buildTableStructure, determineAdjustedIncrementSize, determineBulkInsertionIdentifierGenerationSelectFragment, determineIncrementSize, determineInitialValue, determineOptimizationStrategy, determineSequenceName, determineValueColumnName, generatorKey, getDatabaseStructure, getIdentifierType, getOptimizer, registerExportables, sqlDropStrings, supportsBulkInsertionIdentifierGeneration
public static final String MAX_LO
public void configure(org.hibernate.type.Type type, Properties params, org.hibernate.service.ServiceRegistry serviceRegistry)
configure
in interface org.hibernate.id.Configurable
configure
in class org.hibernate.id.enhanced.SequenceStyleGenerator
public Serializable generate(org.hibernate.engine.spi.SharedSessionContractImplementor session, Object obj) throws org.hibernate.HibernateException
generate
in interface org.hibernate.id.IdentifierGenerator
generate
in class org.hibernate.id.enhanced.SequenceStyleGenerator
org.hibernate.HibernateException
public int getMaxLo()
public void reset()
public String[] sqlCreateStrings(org.hibernate.dialect.Dialect dialect)
sqlCreateStrings
in interface org.hibernate.id.PersistentIdentifierGenerator
sqlCreateStrings
in class org.hibernate.id.enhanced.SequenceStyleGenerator
Copyright © 2003–2023 Atlassian. All rights reserved.
View cookie preferences