MultipleHiLoPerTableGenerator (Hibernate JavaDocs)
Date: 2012-04-05

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.hibernate.id
Class MultipleHiLoPerTableGenerator

    java.lang.Object
      org.hibernate.id.MultipleHiLoPerTableGenerator

All Implemented Interfaces:
  Configurable, IdentifierGenerator, PersistentIdentifierGenerator

    public class MultipleHiLoPerTableGenerator

extends Object
implements PersistentIdentifierGenerator, Configurable

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)

Field Summary
`static String` | `DEFAULT_TABLE`
`static String` | `ID_TABLE`
`static String` | `MAX_LO`
`static String` | `PK_COLUMN_NAME`
`static String` | `PK_LENGTH_NAME`
`static String` | `PK_VALUE_NAME`
`static String` | `VALUE_COLUMN_NAME`

Fields inherited from interface org.hibernate.id.PersistentIdentifierGenerator
`CATALOG, IDENTIFIER_NORMALIZER, PK, SCHEMA, TABLE, TABLES`

Fields inherited from interface org.hibernate.id.IdentifierGenerator
`ENTITY_NAME`

Constructor Summary
`MultipleHiLoPerTableGenerator()`

Method Summary
`void` | `configure(Type type, Properties params, Dialect dialect)` Configure this instance, given the value of parameters specified by the user as `<param>` elements.
`Serializable` | `generate(SessionImplementor session, Object obj)` Generate a new identifier.
`Object` | `generatorKey()` Return a key unique to the underlying database objects.
`String[]` | `sqlCreateStrings(Dialect dialect)` The SQL required to create the underlying database objects.
`String[]` | `sqlDropStrings(Dialect dialect)` The SQL required to remove the underlying database objects.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### ID_TABLE

    public static final String ID_TABLE

See Also:
  Constant Field Values

### PK_COLUMN_NAME

    public static final String PK_COLUMN_NAME

See Also:
  Constant Field Values

### PK_VALUE_NAME

    public static final String PK_VALUE_NAME

See Also:
  Constant Field Values

### VALUE_COLUMN_NAME

    public static final String VALUE_COLUMN_NAME

See Also:
  Constant Field Values

### PK_LENGTH_NAME

    public static final String PK_LENGTH_NAME

See Also:
  Constant Field Values

### DEFAULT_TABLE

    public static final String DEFAULT_TABLE

See Also:
  Constant Field Values

### MAX_LO

    public static final String MAX_LO

See Also:
  Constant Field Values

Constructor Detail

### MultipleHiLoPerTableGenerator

    public MultipleHiLoPerTableGenerator()

Method Detail

### sqlCreateStrings

    public String[] sqlCreateStrings(Dialect dialect)
                              throws HibernateException

  Description copied from interface: `PersistentIdentifierGenerator`
  The SQL required to create the underlying database objects.

  Specified by:
    `sqlCreateStrings` in interface `PersistentIdentifierGenerator`
  Parameters:
    `dialect` - The dialect against which to generate the create command(s)
  Returns:
    The create command(s)
  Throws:
    `HibernateException` - problem creating the create command(s)

### sqlDropStrings

    public String[] sqlDropStrings(Dialect dialect)
                            throws HibernateException

  Description copied from interface: `PersistentIdentifierGenerator`
  The SQL required to remove the underlying database objects.

  Specified by:
    `sqlDropStrings` in interface `PersistentIdentifierGenerator`
  Parameters:
    `dialect` - The dialect against which to generate the drop command(s)
  Returns:
    The drop command(s)
  Throws:
    `HibernateException` - problem creating the drop command(s)

### generatorKey

    public 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`
  Returns:
    Object an identifying key for this generator

### generate

    public Serializable generate(SessionImplementor session,
                                 Object obj)

  Description copied from interface: `IdentifierGenerator`
  Generate a new identifier.

  Specified by:
    `generate` in interface `IdentifierGenerator`
    `obj` - the entity or toplevel collection for which the id is being generated
  Returns:
    a new identifier

### configure

    public void configure(Type type,
                          Properties params,
                          Dialect dialect)
                   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`
    `params` - param values, keyed by parameter name
  Throws:
    `MappingException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2012 Red Hat, Inc. All Rights Reserved.