Configuring automatic key generation

EAServer supports three mechanisms for key generation:

To configure the key generation mechanism and enable automatic key creation, set the keyGenerator attribute in the <persistentObject> Ant command that maps the database table to the entity bean. For example:

<target name="configure-user">
  <setProperties component="ejb.components.example.CustomerInventory">
    <persistentObject
        table="cust_inv"
        isolationLevel="RepeatableRead"
        dataSource=”myDB”
        keyGenerator=”key-gen-value”
    />
  </setProperties>
</target>

The the keyGenerator attribute takes the values listed in Table 4-2.

Table 4-2: keyGenerator attribute values

Value

To specify

sequence seq-name

Oracle sequence seq-name

select @@identity

Sybase style identity column

key-table.key-column += batch-size

Key generator table using the specified table, column name, and key increment batch size. For example, to specify a table named cust_key, using column next_id, and incrementing through 100 keys at a time, set the value to:

cust_key.next_id += 100

Create the key lookup table if it does not exist in the database. EAServer does not create it automatically.