1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2008, 2013 Oracle and/or its affiliates.  All rights reserved.
5  *
6  * $Id$
7  */
8 
9 package com.sleepycat.db;
10 
11 /**
12  * The interface implemented for setting multi-valued foreign keys to null.
13  *
14  * <p>A key nullifier is used with a secondary database that is configured to
15  * have a foreign key integrity constraint and a delete action of {@link
16  * ForeignKeyDeleteAction#NULLIFY}.  The key nullifier is specified by calling
17  * {@link SecondaryConfig#setForeignMultiKeyNullifier}.</p>
18  *
19  * <p>When a referenced record in the foreign key database is deleted and the
20  * foreign key delete action is <code>NULLIFY</code>, the {@link
21  * ForeignMultiKeyNullifier#nullifyForeignKey} method is called.  This method
22  * sets the foreign key reference to null in the datum of the primary
23  * database. The primary database is then updated to contain the modified
24  * datum.  The result is that the secondary key is deleted.</p>
25  *
26  * This interface may be used along with {@link SecondaryKeyCreator} or {@link
27  * SecondaryMultiKeyCreator} for many-to-many, one-to-many, many-to-one and
28  * one-to-one relationships.
29  */
30 public interface ForeignMultiKeyNullifier {
31     /**
32      * Sets the foreign key reference to null in the datum of the primary
33      * database.
34      *
35      * @param secondary the database in which the foreign key integrity
36      * constraint is defined. This parameter is passed for informational
37      * purposes but is not commonly used.
38      *
39      * @param key the existing primary key.  This parameter is passed for
40      * informational purposes but is not commonly used.
41      *
42      * @param data the existing primary datum in which the foreign key
43      * reference should be set to null.  This parameter should be updated by
44      * this method if it returns true.
45      *
46      * @param secKey the secondary key to be nullified.  This parameter is
47      * needed for knowing which key to nullify when multiple keys are present,
48      * as when {@link SecondaryMultiKeyCreator} is used.
49      *
50      * @return true if the datum was modified, or false to indicate that the
51      * key is not present.
52      *
53      * @throws DatabaseException if an error occurs attempting to clear the key
54      * reference.
55      */
nullifyForeignKey(SecondaryDatabase secondary, DatabaseEntry key, DatabaseEntry data, DatabaseEntry secKey)56     boolean nullifyForeignKey(SecondaryDatabase secondary, DatabaseEntry key, DatabaseEntry data, DatabaseEntry secKey)
57 	    throws DatabaseException;
58 }
59