Skip Headers

# Configuring Multiple Sequences

Previous

Next

In addition to using the platform default sequence (see "Using the Platform Default Sequence"), you can explicitly create sequence instances and configure a `Login` with any combination of sequence types, each with their own preallocation size as Example: Configuring Multiple Sequences Explicitly shows. In this example, the sequence named `EMP_SEQ` will provide sequence values exclusively for instances of the `Employee` class and `ADD_SEQ` will provide sequence values exclusively for instances of the `Address` class. The sequence named `PHONE_SEQ` will use the platform default sequence with a preallocation size of 30 to provide sequence values for the `Phone` class.

Configuring Multiple Sequences Explicitly

    login.addSequence(new TableSequence("EMP_SEQ", 25));
    login.addSequence(new DefaultSequence("PHONE_SEQ", 30));
    login.addSequence(new UnaryTableSequence("ADD_SEQ", 55));
    login.addSequence(new NativeSequence("NAT_SEQ", 10));

If login owned a `DatabasePlatform` (whose default sequence type is `TableSequence`), you could configure your sequences using the platform default sequence type as Example: Configuring Multiple Sequences Using the Default Sequence Type shows. In this example, sequences `EMP_SEQ` and `PHONE_SEQ` share the same `TableSequence` table: `EMP_SEQ` and `PHONE_SEQ` represent rows in this table.

Configuring Multiple Sequences Using the Default Sequence Type

    login.addSequence(new DefaultSequence("EMP_SEQ", 25));
    login.addSequence(new DefaultSequence("PHONE_SEQ", 30));
    login.addSequence(new UnaryTableSequence("ADD_SEQ", 55));
    login.addSequence(new NativeSequence("NAT_SEQ", 10));