com.sleepycat.persist.impl
Class PersistKeyCreator

java.lang.Object
  extended by com.sleepycat.persist.impl.PersistKeyCreator
All Implemented Interfaces:
ForeignMultiKeyNullifier, SecondaryKeyCreator, SecondaryMultiKeyCreator

public class PersistKeyCreator
extends java.lang.Object
implements SecondaryKeyCreator, SecondaryMultiKeyCreator, ForeignMultiKeyNullifier

A persistence secondary key creator/nullifier. This class always uses rawAccess=true to avoid depending on the presence of the proxy class.


Constructor Summary
PersistKeyCreator(com.sleepycat.persist.impl.Catalog catalog, EntityMetadata entityMeta, java.lang.String keyClassName, SecondaryKeyMetadata secKeyMeta)
          Creates a key creator/nullifier for a given entity class and key name.
 
Method Summary
 boolean createSecondaryKey(SecondaryDatabase secondary, DatabaseEntry key, DatabaseEntry data, DatabaseEntry result)
          Creates a secondary key entry, given a primary key and data entry.
 void createSecondaryKeys(SecondaryDatabase secondary, DatabaseEntry key, DatabaseEntry data, java.util.Set results)
          Creates a secondary key entry, given a primary key and data entry.
 boolean nullifyForeignKey(SecondaryDatabase secondary, DatabaseEntry key, DatabaseEntry data, DatabaseEntry secKey)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistKeyCreator

public PersistKeyCreator(com.sleepycat.persist.impl.Catalog catalog,
                         EntityMetadata entityMeta,
                         java.lang.String keyClassName,
                         SecondaryKeyMetadata secKeyMeta)
Creates a key creator/nullifier for a given entity class and key name.

Method Detail

createSecondaryKey

public boolean createSecondaryKey(SecondaryDatabase secondary,
                                  DatabaseEntry key,
                                  DatabaseEntry data,
                                  DatabaseEntry result)
                           throws DatabaseException
Description copied from interface: SecondaryKeyCreator
Creates 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:
createSecondaryKey in interface SecondaryKeyCreator
Parameters:
secondary - the database to which the secondary key will be added. This parameter is passed for informational purposes but is not commonly used.

key - the primary key entry. This parameter must not be modified by this method.

data - the primary data entry. This parameter must not be modified by this method.

result - the secondary key created by this method.

Returns:
true if a key was created, or false to indicate that the key is not present.

Throws:
DatabaseException - if an error occurs attempting to create the secondary key.

createSecondaryKeys

public void createSecondaryKeys(SecondaryDatabase secondary,
                                DatabaseEntry key,
                                DatabaseEntry data,
                                java.util.Set results)
                         throws DatabaseException
Description copied from interface: SecondaryMultiKeyCreator
Creates 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. Zero or more secondary keys may be derived from the primary record and returned in the results parameter. To ensure the integrity of a secondary database the key creator method must always return the same results for a given set of input parameters.

Specified by:
createSecondaryKeys in interface SecondaryMultiKeyCreator
Parameters:
secondary - the database to which the secondary key will be added. This parameter is passed for informational purposes but is not commonly used.

key - the primary key entry. This parameter must not be modified by this method.

data - the primary data entry. This parameter must not be modified by this method.

results - the set to contain the the secondary key DatabaseEntry objects created by this method.

Throws:
DatabaseException - if an error occurs attempting to create the secondary key.

nullifyForeignKey

public boolean nullifyForeignKey(SecondaryDatabase secondary,
                                 DatabaseEntry key,
                                 DatabaseEntry data,
                                 DatabaseEntry secKey)
                          throws DatabaseException
Specified by:
nullifyForeignKey in interface ForeignMultiKeyNullifier
Throws:
DatabaseException