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 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.

Author:
Mark Hayes

Constructor Summary
PersistKeyCreator(Catalog catalog, EntityMetadata entityMeta, String keyClassName, SecondaryKeyMetadata secKeyMeta, boolean rawAccess)
          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, Set results)
          Creates a secondary key entry, given a primary key and data entry.
(package private) static boolean isManyType(Class cls)
           
 boolean nullifyForeignKey(SecondaryDatabase secondary, DatabaseEntry key, DatabaseEntry data, DatabaseEntry secKey)
          Sets the foreign key reference to null in the datum of the primary database.
(package private)  void refresh(PersistCatalog newCatalog)
          See Store.refresh.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistKeyCreator

public PersistKeyCreator(Catalog catalog,
                         EntityMetadata entityMeta,
                         String keyClassName,
                         SecondaryKeyMetadata secKeyMeta,
                         boolean rawAccess)
Creates a key creator/nullifier for a given entity class and key name.

Method Detail

isManyType

static boolean isManyType(Class cls)

createSecondaryKey

public boolean createSecondaryKey(SecondaryDatabase secondary,
                                  DatabaseEntry key,
                                  DatabaseEntry data,
                                  DatabaseEntry result)
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.

A RuntimeException may be thrown by this method if an error occurs attempting to create the secondary key. This exception will be thrown by the API method currently in progress, for example, a put method. However, this will cause the write operation to be incomplete. When databases are not configured to be transactional, caution should be used to avoid integrity problems. See Special considerations for using Secondary Databases with and without Transactions.

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.

createSecondaryKeys

public void createSecondaryKeys(SecondaryDatabase secondary,
                                DatabaseEntry key,
                                DatabaseEntry data,
                                Set results)
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.

A RuntimeException may be thrown by this method if an error occurs attempting to create the secondary key. This exception will be thrown by the API method currently in progress, for example, a put method. However, this will cause the write operation to be incomplete. When databases are not configured to be transactional, caution should be used to avoid integrity problems. See Special considerations for using Secondary Databases with and without Transactions.

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.

nullifyForeignKey

public boolean nullifyForeignKey(SecondaryDatabase secondary,
                                 DatabaseEntry key,
                                 DatabaseEntry data,
                                 DatabaseEntry secKey)
Description copied from interface: ForeignMultiKeyNullifier
Sets the foreign key reference to null in the datum of the primary database.

Specified by:
nullifyForeignKey in interface ForeignMultiKeyNullifier
Parameters:
secondary - the database in which the foreign key integrity constraint is defined. This parameter is passed for informational purposes but is not commonly used.
key - the existing primary key. This parameter is passed for informational purposes but is not commonly used.
data - 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.
secKey - the secondary key to be nullified. This parameter is needed for knowing which key to nullify when multiple keys are present, as when SecondaryMultiKeyCreator is used.
Returns:
true if the datum was modified, or false to indicate that the key is not present.

refresh

void refresh(PersistCatalog newCatalog)
See Store.refresh.



Copyright (c) 2004-2010 Oracle. All rights reserved.