How do I use Unique IDs?

Designing Unique IDs into your Cúram application is straightforward. In your UML application model, set the appropriate domain definitions to be of the data type SVR_INT64. The developer's view of this is as a Java Long primitive. To allocate a new Unique ID call UniqueID.nextUniqueID(), passing a key set name as a string. This call transparently looks after allocating a new Unique ID block if necessary. If no key set name is passed to the nextUniqueID() method the default key set, curam.util.resources.KeySet.kKeySetDefault, is used. This key set allocates non human-readable Unique IDs.

Key sets are defined by configuring entries in the KeyServer database table. This can be done by creating a DMX file defining all key entries. How do I use Unique IDs? details the fields of the KeyServer database table.

Table 1. KeyServer Database Table

Field

Description

keySetCode

An identifier for the key set, e.g. MYKEYSET.

nextUniqueIdBlock

The next Unique ID block that should be allocated. For human-readable IDs this field can be used to skip pre-allocated Unique IDs.

humanReadable

True if the Unique IDs should be human-readable.

lastUpdated

The timestamp for when the entry was last updated.

strategy

Represents strategy used to generate next unique id block for a given key set.

Annotation

A description of the key set.

If you are using human-readable Unique IDs, and non-Cúram-generated keys have already been allocated, then you can guarantee that these values will never be re-allocated by Cúram (i.e. Unique IDs will never "clash"). This is achieved by setting the nextUniqueIdBlock field on the KeyServer database table to be Ceiling(N/256), where N is the number of Unique IDs which have already been pre-allocated.

The strategy field is used to specify whether the standard Key Server or the Range Aware Key Server is used for the key set. If the field is set to null, the standard Key Server is used. If the field is set to a specific value KB1002 then the Range Aware Key Server will be used to generate next unique id block for the key set. The Range Aware Key Server is explained in more detail in Range Aware Key Server.

Warning: Care should be taken when defining and using custom key sets. The same key set should always be used when using Unique IDs as the primary key for a particular database table. If two key sets are used to generate Unique IDs for the same database table, duplicate record problems may occur. Unique IDs are only unique within a particular key set.
Note: The conversion routine for hexadecimal numbers that are used as Unique IDs on a DB2 for z/OS database can only support numbers between Long.MAX_VALUE and Long.MIN_VALUE + 1.