Class SerialSerialKeyCreator<PK,D,SK>
- All Implemented Interfaces:
ForeignKeyNullifier,SecondaryKeyCreator
If ForeignKeyDeleteAction.NULLIFY was
specified when opening the secondary database, the following method must be
overridden to nullify the foreign index key. If NULLIFY was not specified,
this method need not be overridden.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SerialBinding<D> protected SerialBinding<SK> protected SerialBinding<PK> -
Constructor Summary
ConstructorsConstructorDescriptionSerialSerialKeyCreator(ClassCatalog classCatalog, Class<PK> primaryKeyClass, Class<D> dataClass, Class<SK> indexKeyClass) Creates a serial-serial key creator.SerialSerialKeyCreator(SerialBinding<PK> primaryKeyBinding, SerialBinding<D> dataBinding, SerialBinding<SK> indexKeyBinding) Creates a serial-serial entity binding. -
Method Summary
Modifier and TypeMethodDescriptionbooleancreateSecondaryKey(SecondaryDatabase db, DatabaseEntry primaryKeyEntry, DatabaseEntry dataEntry, DatabaseEntry indexKeyEntry) Creates a secondary key entry, given a primary key and data entry.abstract SKcreateSecondaryKey(PK primaryKey, D data) Creates the index key object from primary key and data objects.booleannullifyForeignKey(SecondaryDatabase db, DatabaseEntry dataEntry) Sets the foreign key reference to null in the datum of the primary database.nullifyForeignKey(D data) Clears the index key in a data object.
-
Field Details
-
-
dataBinding
-
indexKeyBinding
-
-
Constructor Details
-
SerialSerialKeyCreator
public SerialSerialKeyCreator(ClassCatalog classCatalog, Class<PK> primaryKeyClass, Class<D> dataClass, Class<SK> indexKeyClass) Creates a serial-serial key creator.- Parameters:
classCatalog- is the catalog to hold shared class information and for a database should be aStoredClassCatalog.primaryKeyClass- is the primary key base class.dataClass- is the data base class.indexKeyClass- is the index key base class.
-
SerialSerialKeyCreator
public SerialSerialKeyCreator(SerialBinding<PK> primaryKeyBinding, SerialBinding<D> dataBinding, SerialBinding<SK> indexKeyBinding) Creates a serial-serial entity binding.- Parameters:
primaryKeyBinding- is the primary key binding.dataBinding- is the data binding.indexKeyBinding- is the index key binding.
-
-
Method Details
-
createSecondaryKey
public boolean createSecondaryKey(SecondaryDatabase db, DatabaseEntry primaryKeyEntry, DatabaseEntry dataEntry, DatabaseEntry indexKeyEntry) Description copied from interface:SecondaryKeyCreatorCreates a secondary key entry, given a primary key and data entry.A secondary key may be derived from the primary key, primary data, or a combination of the primary key and data. For secondary keys that are optional, the key creator method may return false and the key/data pair will not be indexed. To ensure the integrity of a secondary database the key creator method must always return the same result for a given set of input parameters.
- Specified by:
createSecondaryKeyin interfaceSecondaryKeyCreator- Parameters:
db- the database to which the secondary key will be added. This parameter is passed for informational purposes but is not commonly used.primaryKeyEntry- the primary key entry. This parameter must not be modified by this method.dataEntry- the primary data entry. This parameter must not be modified by this method.indexKeyEntry- the secondary key created by this method.- Returns:
- true if a key was created, or false to indicate that the key is not present.
-
nullifyForeignKey
Description copied from interface:ForeignKeyNullifierSets the foreign key reference to null in the datum of the primary database.- Specified by:
nullifyForeignKeyin interfaceForeignKeyNullifier- Parameters:
db- the database in which the foreign key integrity constraint is defined. This parameter is passed for informational purposes but is not commonly used.dataEntry- the existing primary datum in which the foreign key reference should be set to null. This parameter should be updated by this method if it returns true.- Returns:
- true if the datum was modified, or false to indicate that the key is not present.
-
createSecondaryKey
Creates the index key object from primary key and data objects.- Parameters:
primaryKey- is the deserialized source primary key entry, or null if no primary key entry is used to construct the index key.data- is the deserialized source data entry, or null if no data entry is used to construct the index key.- Returns:
- the destination index key object, or null to indicate that the key is not present.
-
nullifyForeignKey
Clears the index key in a data object.On entry the data parameter contains the index key to be cleared. It should be changed by this method such that
createSecondaryKey(com.sleepycat.db.SecondaryDatabase, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.DatabaseEntry, com.sleepycat.db.DatabaseEntry)will return false. Other fields in the data object should remain unchanged.- Parameters:
data- is the source and destination data object.- Returns:
- the destination data object, or null to indicate that the key is not present and no change is necessary. The data returned may be the same object passed as the data parameter or a newly created object.
-