Class ResettableTableHiLoGenerator
java.lang.Object
org.hibernate.id.enhanced.SequenceStyleGenerator
com.atlassian.confluence.impl.hibernate.ResettableTableHiLoGenerator
- All Implemented Interfaces:
- BulkIdGenerator,- org.hibernate.boot.model.relational.ExportableProducer,- org.hibernate.id.BulkInsertionCapableIdentifierGenerator,- org.hibernate.id.Configurable,- org.hibernate.id.IdentifierGenerator,- org.hibernate.id.PersistentIdentifierGenerator
- Direct Known Subclasses:
- ResettableTableHiLoGeneratorV5
public class ResettableTableHiLoGenerator
extends org.hibernate.id.enhanced.SequenceStyleGenerator
implements BulkIdGenerator
An implementation of a resettable hi/lo 
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
- Since:
- 7.17
- 
Field SummaryFieldsFields inherited from class org.hibernate.id.enhanced.SequenceStyleGeneratorCONFIG_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_PARAMFields inherited from interface org.hibernate.id.IdentifierGeneratorENTITY_NAME, GENERATOR_NAME, JPA_ENTITY_NAMEFields inherited from interface org.hibernate.id.PersistentIdentifierGeneratorCATALOG, IDENTIFIER_NORMALIZER, PK, SCHEMA, TABLE, TABLES
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidconfigure(org.hibernate.type.Type type, Properties params, org.hibernate.service.ServiceRegistry serviceRegistry) generate(org.hibernate.engine.spi.SharedSessionContractImplementor session, Object fakeHibernateObject, int count) Generate a collection of ids.intgetMaxLo()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.voidreset()Set the lo value to more than maxLo to force a reset of the hi value.Methods inherited from class org.hibernate.id.enhanced.SequenceStyleGeneratorbuildDatabaseStructure, buildSequenceStructure, buildTableStructure, determineAdjustedIncrementSize, determineBulkInsertionIdentifierGenerationSelectFragment, determineIncrementSize, determineInitialValue, determineOptimizationStrategy, determineSequenceName, determineValueColumnName, generatorKey, getDatabaseStructure, getIdentifierType, getOptimizer, initialize, isPhysicalSequence, registerExportables, supportsBulkInsertionIdentifierGenerationMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.id.BulkInsertionCapableIdentifierGeneratordetermineBulkInsertionIdentifierGenerationSelectFragmentMethods inherited from interface org.hibernate.id.IdentifierGeneratorsupportsJdbcBatchInserts
- 
Field Details- 
MAX_LOThe max_lo parameter- See Also:
 
 
- 
- 
Constructor Details- 
ResettableTableHiLoGeneratorpublic ResettableTableHiLoGenerator()
 
- 
- 
Method Details- 
configurepublic void configure(org.hibernate.type.Type type, Properties params, org.hibernate.service.ServiceRegistry serviceRegistry) - Specified by:
- configurein interface- org.hibernate.id.Configurable
- Specified by:
- configurein interface- org.hibernate.id.IdentifierGenerator
- Overrides:
- configurein class- org.hibernate.id.enhanced.SequenceStyleGenerator
 
- 
getMaxLopublic 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.
- 
resetpublic void reset()Set the lo value to more than maxLo to force a reset of the hi value.
 
-