Berkeley DB Java Edition
version 1.5.1

com.sleepycat.je
Class SecondaryConfig

java.lang.Object
  |
  +--com.sleepycat.je.DatabaseConfig
        |
        +--com.sleepycat.je.SecondaryConfig
All Implemented Interfaces:
Cloneable

public class SecondaryConfig
extends DatabaseConfig

The configuration properties of a SecondaryDatabase extend those of a primary Database. The secondary database configuration is specified when calling Environment.openSecondaryDatabase.

To create a configuration object with default attributes:

  SecondaryConfig config = new SecondaryConfig();
To set custom attributes:
  SecondaryConfig config = new SecondaryConfig();
  config.setAllowCreate(true);
  config.setAllowPopulate(true);

NOTE: There are two situations where the use of secondary databases without transactions requires special consideration. When using a transactional database or when doing read operations only, this note does not apply.

In both cases, the operation will be partially complete because the primary database record will have already been updated or deleted. In the presence of transactions, the exception will cause the transaction to abort. Without transactions, it is the responsibility of the caller to handle the results of the incomplete update or to take steps to prevent this situation from happening in the first place.

See Also:
Environment.openSecondaryDatabase, SecondaryDatabase

Constructor Summary
SecondaryConfig()
          Creates an instance with the system's default settings.
 
Method Summary
 boolean getAllowPopulate()
          Returns whether automatic population of the secondary is allowed.
 Database getForeignKeyDatabase()
          Returns the database used to check the foreign key integrity constraint, or null if no foreign key constraint will be checked.
 ForeignKeyDeleteAction getForeignKeyDeleteAction()
          Returns the action taken when a referenced record in the foreign key database is deleted.
 ForeignKeyNullifier getForeignKeyNullifier()
          Returns the user-supplied object used for setting foreign keys to null.
 SecondaryKeyCreator getKeyCreator()
          Returns the user-supplied object used for creating secondary keys.
 void setAllowPopulate(boolean allowPopulate)
          Specifies whether automatic population of the secondary is allowed.
 void setForeignKeyDatabase(Database foreignKeyDatabase)
          Defines a foreign key integrity constraint for a given foreign key database.
 void setForeignKeyDeleteAction(ForeignKeyDeleteAction foreignKeyDeleteAction)
          Specifies the action taken when a referenced record in the foreign key database is deleted.
 void setForeignKeyNullifier(ForeignKeyNullifier foreignKeyNullifier)
          Specifies the user-supplied object used for setting foreign keys to null.
 void setKeyCreator(SecondaryKeyCreator keyCreator)
          Specifies the user-supplied object used for creating secondary keys.
 
Methods inherited from class com.sleepycat.je.DatabaseConfig
getAllowCreate, getBtreeComparator, getDuplicateComparator, getExclusiveCreate, getOverrideBtreeComparator, getOverrideDuplicateComparator, getReadOnly, getSortedDuplicates, getTransactional, setAllowCreate, setBtreeComparator, setDuplicateComparator, setExclusiveCreate, setOverrideBtreeComparator, setOverrideDuplicateComparator, setReadOnly, setSortedDuplicates, setTransactional
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecondaryConfig

public SecondaryConfig()
Creates an instance with the system's default settings.

Method Detail

setKeyCreator

public void setKeyCreator(SecondaryKeyCreator keyCreator)
Specifies the user-supplied object used for creating secondary keys.

Unless the primary database is read-only, a key creator is required when opening a secondary database.

Parameters:
keyCreator - the user-supplied object used for creating secondary keys.

getKeyCreator

public SecondaryKeyCreator getKeyCreator()
Returns the user-supplied object used for creating secondary keys.

Returns:
the user-supplied object used for creating secondary keys.
See Also:
setKeyCreator(com.sleepycat.je.SecondaryKeyCreator)

setAllowPopulate

public void setAllowPopulate(boolean allowPopulate)
Specifies whether automatic population of the secondary is allowed.

If automatic population is allowed, when the secondary database is opened it is checked to see if it is empty. If it is empty, the primary database is read in its entirety and keys are added to the secondary database using the information read from the primary.

If this property is set to true and the environment is transactional, the secondary database must be opened within a transaction.

Parameters:
allowPopulate - whether automatic population of the secondary is allowed.

getAllowPopulate

public boolean getAllowPopulate()
Returns whether automatic population of the secondary is allowed. If setAllowPopulate(boolean) has not been called, this method returns false.

Returns:
whether automatic population of the secondary is allowed.
See Also:
setAllowPopulate(boolean)

setForeignKeyDatabase

public void setForeignKeyDatabase(Database foreignKeyDatabase)
Defines a foreign key integrity constraint for a given foreign key database.

If this property is non-null, a record must be present in the specified foreign database for every record in the secondary database, where the secondary key value is equal to the foreign database key value. Whenever a record is to be added to the secondary database, the secondary key is used as a lookup key in the foreign database. If the key is not found in the foreign database, a DatabaseException is thrown.

Parameters:
foreignKeyDatabase - the database used to check the foreign key integrity constraint, or null if no foreign key constraint should be checked.

getForeignKeyDatabase

public Database getForeignKeyDatabase()
Returns the database used to check the foreign key integrity constraint, or null if no foreign key constraint will be checked.

Returns:
the foreign key database, or null.
See Also:
setForeignKeyDatabase(com.sleepycat.je.Database)

setForeignKeyDeleteAction

public void setForeignKeyDeleteAction(ForeignKeyDeleteAction foreignKeyDeleteAction)
Specifies the action taken when a referenced record in the foreign key database is deleted.

This property is ignored if the foreign key database property is null.

Parameters:
foreignKeyDeleteAction - the action taken when a referenced record in the foreign key database is deleted.
See Also:
ForeignKeyDeleteAction, setForeignKeyDatabase(com.sleepycat.je.Database)

getForeignKeyDeleteAction

public ForeignKeyDeleteAction getForeignKeyDeleteAction()
Returns the action taken when a referenced record in the foreign key database is deleted.

Returns:
the action taken when a referenced record in the foreign key database is deleted.
See Also:
setForeignKeyDeleteAction(com.sleepycat.je.ForeignKeyDeleteAction)

setForeignKeyNullifier

public void setForeignKeyNullifier(ForeignKeyNullifier foreignKeyNullifier)
Specifies the user-supplied object used for setting foreign keys to null.

If the foreign key database property is non-null and the foreign key delete action is NULLIFY, this property is required to be non-null; otherwise, this property is ignored.

Parameters:
foreignKeyNullifier - the user-supplied object used for setting foreign keys to null.
See Also:
ForeignKeyNullifier, ForeignKeyDeleteAction.NULLIFY, setForeignKeyDatabase(com.sleepycat.je.Database)

getForeignKeyNullifier

public ForeignKeyNullifier getForeignKeyNullifier()
Returns the user-supplied object used for setting foreign keys to null.

Returns:
the user-supplied object used for setting foreign keys to null.
See Also:
setForeignKeyNullifier(com.sleepycat.je.ForeignKeyNullifier)

Berkeley DB Java Edition
version 1.5.1

Copyright (c) 1996-2004 Sleepycat Software, Inc. - All rights reserved.