| com.sleepycat.persist.model.SecondaryKey
SecondaryKey | public @interface SecondaryKey(Code) | | |
Field Summary | |
String | name Specifies the name of the key in order to use a name that is different
than the field name.
This is convenient when prefixes or suffices are used on field names.
For example:
class Person {
String m_parentSsn;
}
It can also be used to uniquely name a key when multiple secondary
keys for a single entity class have the same field name. | DeleteAction | onRelatedEntityDelete Specifies the action to take when a related entity is deleted having a
primary key value that exists as a secondary key value for this entity.
Note: This property only applies when
SecondaryKey.relatedEntity is specified to define the related entity.
The default action,
DeleteAction.ABORT ABORT , means that a
DatabaseException is thrown in order to abort the current
transaction.
If
DeleteAction.CASCADE CASCADE is specified, then this
entity will be deleted also. | Relationship | relate Defines the relationship between instances of the entity class and the
secondary keys.
The table below summarizes how to create all four variations of
relationships.
For a many-to-x relationship, the secondary index will
have non-unique keys; in other words, duplicates will be allowed.
Conversely, for one-to-x relationship, the secondary index
will have unique keys.
For a x-to-one relationship, the secondary key field is
singular; in other words, it may not be an array or collection type.
Conversely, for a x-to-many relationship, the secondary key
field must be an array or collection type. | Class | relatedEntity Specifies the entity to which this entity is related, for establishing
foreign key constraints. |
name | String name(Code) | | Specifies the name of the key in order to use a name that is different
than the field name.
This is convenient when prefixes or suffices are used on field names.
For example:
class Person {
String m_parentSsn;
}
It can also be used to uniquely name a key when multiple secondary
keys for a single entity class have the same field name. For example,
an entity class and its subclass may both have a field named 'date',
and both fields are used as secondary keys. The
name property
can be specified for one or both fields to give each key a unique
name.
|
onRelatedEntityDelete | DeleteAction onRelatedEntityDelete(Code) | | Specifies the action to take when a related entity is deleted having a
primary key value that exists as a secondary key value for this entity.
Note: This property only applies when
SecondaryKey.relatedEntity is specified to define the related entity.
The default action,
DeleteAction.ABORT ABORT , means that a
DatabaseException is thrown in order to abort the current
transaction.
If
DeleteAction.CASCADE CASCADE is specified, then this
entity will be deleted also. This in turn could trigger further
deletions, causing a cascading effect.
If
DeleteAction.NULLIFY NULLIFY is specified, then the
secondary key in this entity is set to null and this entity is updated.
If the key field type is singular, the field value is set to null;
therefore, to specify
NULLIFY for a singular key field type, a
primitive wrapper type must be used instead of a primitive type. If the
key field type is an array or collection type, the key is deleted from
the array (the array is resized) or from the collection (using
java.util.Collection.remove Collection.remove ).
|
relate | Relationship relate(Code) | | Defines the relationship between instances of the entity class and the
secondary keys.
The table below summarizes how to create all four variations of
relationships.
For a many-to-x relationship, the secondary index will
have non-unique keys; in other words, duplicates will be allowed.
Conversely, for one-to-x relationship, the secondary index
will have unique keys.
For a x-to-one relationship, the secondary key field is
singular; in other words, it may not be an array or collection type.
Conversely, for a x-to-many relationship, the secondary key
field must be an array or collection type. A collection type is any
implementation of
java.util.Collection .
|
relatedEntity | Class relatedEntity(Code) | | Specifies the entity to which this entity is related, for establishing
foreign key constraints. Values of this secondary key will be
constrained to the set of primary key values for the given entity class.
The given class must be an entity class. This class is called the
related entity or foreign entity.
When a related entity class is specified, a check (foreign key
constraint) is made every time a new secondary key value is stored for
this entity, and every time a related entity is deleted.
Whenever a new secondary key value is stored for this entity, it is
checked to ensure it exists as a primary key value of the related
entity. If it does not, a
DatabaseException will be thrown
by the
PrimaryIndex
put method.
Whenever a related entity is deleted and its primary key value exists
as a secondary key value for this entity, the action is taken that is
specified using the
SecondaryKey.onRelatedEntityDelete property.
Together, these two checks guarantee that a secondary key value for
this entity will always exist as a primary key value for the related
entity. Note, however, that a transactional store must be configured
to guarantee this to be true in the face of a crash; see
StoreConfig.setTransactional .
|
|
|