The name of a sequence from which to assign primary key values
automatically. If a non-empty string is specified, sequential integers
will be assigned from the named sequence.
A single sequence may be used for more than one entity class by
specifying the same sequence name for each
PrimaryKey . For
each named sequence, a
com.sleepycat.je.Sequence will be used to
assign key values. For more information on configuring sequences, see
EntityStore.setSequenceConfig EntityStore.setSequenceConfig .
To use a sequence, the type of the key field must be a primitive
integer type (
byte ,
short ,
int or
long )
or the primitive wrapper class for one of these types. A composite key
class may also be used to override sort order, but it may contain only a
single key field that has one of the types previously mentioned.
When an entity with a primary key sequence is stored using one of the
put methods in the
PrimaryIndex , a new key will be
assigned if the primary key field in the entity instance is null (for a
reference type) or zero (for a primitive integer type). Specifying zero
for a primitive integer key field is allowed because the initial value
of the sequence is one (not zero) by default. If the sequence
configuration is changed such that zero is part of the sequence, then
the field type must be a primitive wrapper class and the field value
must be null to cause a new key to be assigned.
When one of the put methods in the
PrimaryIndex is called and a new key is assigned, the assigned value is returned to
the caller via the key field of the entity object that is passed as a
parameter.
|