Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Berkeley DB version 4.3.29
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sleepycat.db
Class SecondaryConfig

    java.lang.Object
      com.sleepycat.db.DatabaseConfig
          com.sleepycat.db.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.

- If secondary is configured to not allow duplicates, when the secondary is being updated it is possible that an error will occur when the secondary key value in a record being added is already present in the database. A `DatabaseException` will be thrown in this situation.
- If a foreign key constraint is configured with the delete action `ABORT` (the default setting), a `DatabaseException` will be thrown if an attempt is made to delete a referenced foreign key.

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`

Field Summary
`static SecondaryConfig` | `DEFAULT`

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.
`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` | `setKeyCreator(SecondaryKeyCreator keyCreator)` Specifies the user-supplied object used for creating secondary keys.

Methods inherited from class com.sleepycat.db.DatabaseConfig
`getAllowCreate, getBtreeComparator, getBtreeMinKey, getBtreePrefixCalculator, getBtreeRecordNumbers, getByteOrder, getByteSwapped, getCacheCount, getCacheSize, getChecksum, getDirtyRead, getDuplicateComparator, getEncrypted, getErrorHandler, getErrorPrefix, getErrorStream, getExclusiveCreate, getFeedbackHandler, getHasher, getHashFillFactor, getHashNumElements, getMessageHandler, getMessageStream, getMode, getNoMMap, getPageSize, getPanicHandler, getQueueExtentSize, getQueueInOrder, getReadOnly, getRecordDelimiter, getRecordLength, getRecordNumberAppender, getRecordPad, getRecordSource, getRenumbering, getReverseSplitOff, getSnapshot, getSortedDuplicates, getTransactional, getTransactionNotDurable, getTruncate, getType, getUnsortedDuplicates, getXACreate, setAllowCreate, setBtreeComparator, setBtreeMinKey, setBtreePrefixCalculator, setBtreeRecordNumbers, setByteOrder, setCacheCount, setCacheSize, setChecksum, setDirtyRead, setDuplicateComparator, setEncrypted, setErrorHandler, setErrorPrefix, setErrorStream, setExclusiveCreate, setFeedbackHandler, setHasher, setHashFillFactor, setHashNumElements, setMessageHandler, setMessageStream, setMode, setNoMMap, setPageSize, setPanicHandler, setQueueExtentSize, setQueueInOrder, setReadOnly, setRecordDelimiter, setRecordLength, setRecordNumberAppender, setRecordPad, setRecordSource, setRenumbering, setReverseSplitOff, setSnapshot, setSortedDuplicates, setTransactional, setTransactionNotDurable, setTruncate, setType, setUnsortedDuplicates, setXACreate`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### DEFAULT

    public static final SecondaryConfig DEFAULT

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.db.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)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Berkeley DB version 4.3.29
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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