Package com.atlassian.bamboo.persistence
Class ResettableTableHiLoGenerator
- java.lang.Object
-
- com.atlassian.bamboo.persistence.ResettableTableHiLoGenerator
-
- All Implemented Interfaces:
org.hibernate.boot.model.relational.ExportableProducer
,org.hibernate.id.Configurable
,org.hibernate.id.IdentifierGenerator
,org.hibernate.id.PersistentIdentifierGenerator
public class ResettableTableHiLoGenerator extends Object implements org.hibernate.id.PersistentIdentifierGenerator, org.hibernate.id.Configurable
An implementation of a resettable hi/loIdentifierGenerator
which is compatible with Hibernate 5.hilo
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
-
-
Constructor Summary
Constructors Constructor Description ResettableTableHiLoGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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
initialize(org.hibernate.boot.model.relational.SqlStringGenerationContext context)
void
registerExportables(org.hibernate.boot.model.relational.Database database)
void
reset()
Set the lo value to more than maxLo to force a reset of the hi value.boolean
supportsJdbcBatchInserts()
-
-
-
Field Detail
-
MAX_LO
public static final String MAX_LO
The max_lo parameter- See Also:
- Constant Field Values
-
-
Method Detail
-
configure
public void configure(org.hibernate.type.Type type, Properties params, org.hibernate.service.ServiceRegistry serviceRegistry) throws org.hibernate.MappingException
- Specified by:
configure
in interfaceorg.hibernate.id.Configurable
- Specified by:
configure
in interfaceorg.hibernate.id.IdentifierGenerator
- Throws:
org.hibernate.MappingException
-
initialize
public void initialize(org.hibernate.boot.model.relational.SqlStringGenerationContext context)
- Specified by:
initialize
in interfaceorg.hibernate.id.IdentifierGenerator
-
supportsJdbcBatchInserts
public boolean supportsJdbcBatchInserts()
- Specified by:
supportsJdbcBatchInserts
in interfaceorg.hibernate.id.IdentifierGenerator
-
generate
public Serializable generate(org.hibernate.engine.spi.SharedSessionContractImplementor session, Object obj) throws org.hibernate.HibernateException
- Specified by:
generate
in interfaceorg.hibernate.id.IdentifierGenerator
- Throws:
org.hibernate.HibernateException
-
reset
public void reset()
Set the lo value to more than maxLo to force a reset of the hi value.
-
registerExportables
public void registerExportables(org.hibernate.boot.model.relational.Database database)
- Specified by:
registerExportables
in interfaceorg.hibernate.boot.model.relational.ExportableProducer
- Specified by:
registerExportables
in interfaceorg.hibernate.id.IdentifierGenerator
-
getMaxLo
public 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.
-
-