Class MultipleHiLoPerTableGenerator

  • All Implemented Interfaces:
    ExportableProducer, Configurable, IdentifierGenerator, PersistentIdentifierGenerator

    public class MultipleHiLoPerTableGenerator
    extends java.lang.Object
    implements PersistentIdentifierGenerator, Configurable
    Use TableGenerator instead.
    A hilo IdentifierGenerator that returns a Long, constructed using a hi/lo algorithm. The hi value MUST be fetched in a seperate 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).

    A hilo IdentifierGenerator that uses a database table to store the last generated values. A table can contains several hi values. They are distinct from each other through a key

    This implementation is not compliant with a user connection

    Allowed parameters (all of them are optional):

    • table: table name (default hibernate_sequences)
    • primary_key_column: key column name (default sequence_name)
    • value_column: hi value column name(default sequence_next_hi_value)
    • primary_key_value: key value for the current entity (default to the entity's primary table name)
    • primary_key_length: length of the key column in DB represented as a varchar (default to 255)
    • max_lo: max low value before increasing hi (default to Short.MAX_VALUE)
    • Constructor Detail

      • MultipleHiLoPerTableGenerator

        public MultipleHiLoPerTableGenerator()
    • Method Detail

      • generate

        public generate​(SharedSessionContractImplementor session,
                                             java.lang.Object obj)
        Description copied from interface: IdentifierGenerator
        Generate a new identifier.
        Specified by:
        generate in interface IdentifierGenerator
        session - The session from which the request originates
        obj - the entity or collection (idbag) for which the id is being generated
        a new identifier
      • configure

        public void configure​(Type type,
                              java.util.Properties params,
                              ServiceRegistry serviceRegistry)
                       throws MappingException
        Description copied from interface: Configurable
        Configure this instance, given the value of parameters specified by the user as <param> elements. This method is called just once, following instantiation.
        Specified by:
        configure in interface Configurable
        type - The id property type descriptor
        params - param values, keyed by parameter name
        serviceRegistry - Access to service that may be needed.
      • determineGeneratorTableName

        protected QualifiedName determineGeneratorTableName​(java.util.Properties params,
                                                            JdbcEnvironment jdbcEnvironment)
      • determineSegmentColumnName

        protected java.lang.String determineSegmentColumnName​(java.util.Properties params,
                                                              JdbcEnvironment jdbcEnvironment)
      • determineValueColumnName

        protected java.lang.String determineValueColumnName​(java.util.Properties params,
                                                            JdbcEnvironment jdbcEnvironment)
      • generatorKey

        public java.lang.Object generatorKey()
        Description copied from interface: PersistentIdentifierGenerator
        Return a key unique to the underlying database objects. Prevents us from trying to create/remove them multiple times.
        Specified by:
        generatorKey in interface PersistentIdentifierGenerator
        Object an identifying key for this generator