SSecondaryConfig (Oracle - Berkeley DB Client-Server API)
Date: 2018-05-29

com.sleepycat.client

## Class SSecondaryConfig

- java.lang.Object
- - com.sleepycat.client.SDatabaseConfig
  - - com.sleepycat.client.SSecondaryConfig

-     public class SSecondaryConfig
      extends SDatabaseConfig

  The configuration properties of a SSecondaryDatabase extend those of a primary SDatabase. The secondary database configuration is specified when calling `SEnvironment.openSecondaryDatabase(com.sleepycat.client.STransaction, java.lang.String, java.lang.String, com.sleepycat.client.SDatabase, com.sleepycat.client.SSecondaryConfig)`.

  To create a configuration object with default attributes:

        SecondaryConfig config = new SecondaryConfig();

  To set custom attributes:

        SSecondaryConfig config = new SSecondaryConfig();
        config.setAllowCreate(true);
        config.setSortedDuplicates(true);
        config.setKeyCreator(new MyKeyCreator());

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SSecondaryConfig()` Creates an instance with the system's default settings.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `SSecondaryConfig` | `cloneConfig()` Create a deep copy of this configuration object.
    `boolean` | `getAllowPopulate()` Returns whether automatic population of the secondary is allowed.
    `protected java.lang.Object` | `getField(F field)` Return the value set on a specified field.
    `SDatabase` | `getForeignKeyDatabase()` Return the database used to check the foreign key integrity constraint, or null if no foreign key constraint will be checked.
    `SForeignKeyDeleteAction` | `getForeignKeyDeleteAction()` Return the action taken when a referenced record in the foreign key database is deleted.
    `SForeignKeyNullifier` | `getForeignKeyNullifier()` Returns the user-supplied object used for setting single-valued foreign keys to null.
    `SForeignMultiKeyNullifier` | `getForeignMultiKeyNullifier()` Returns the user-supplied object used for setting multi-valued foreign keys to null.
    `boolean` | `getImmutableSecondaryKey()` Return whether the secondary key is immutable.
    `SSecondaryKeyCreator` | `getKeyCreator()` Return the user-supplied object used for creating single-valued secondary keys.
    `SSecondaryMultiKeyCreator` | `getMultiKeyCreator()` Return the user-supplied object used for creating multi-valued secondary keys.
    `protected T` | `getThriftObj()`
    `SSecondaryConfig` | `setAllowPopulate(boolean allowPopulate)` Specifies whether automatic population of the secondary is allowed.
    `SSecondaryConfig` | `setForeignKeyDatabase(SDatabase foreignDb)` Define a foreign key integrity constraint for a given foreign key database.
    `SSecondaryConfig` | `setForeignKeyDeleteAction(SForeignKeyDeleteAction action)` Specify the action taken when a referenced record in the foreign key database is deleted.
    `void` | `setForeignKeyNullifier(SForeignKeyNullifier keyNullifier)` Specifies the user-supplied object used for setting single-valued foreign keys to null.
    `void` | `setForeignMultiKeyNullifier(SForeignMultiKeyNullifier multiKeyNullifier)` Specifies the user-supplied object used for setting multi-valued foreign keys to null.
    `SSecondaryConfig` | `setImmutableSecondaryKey(boolean immutableSecondaryKey)` Specify whether the secondary key is immutable.
    `SSecondaryConfig` | `setKeyCreator(SSecondaryKeyCreator keyCreator)` Specify the user-supplied object used for creating single-valued secondary keys.
    `void` | `setMultiKeyCreator(SSecondaryMultiKeyCreator multiKeyCreator)` Specify the user-supplied object used for creating multi-valued secondary keys.

    - ### Methods inherited from class com.sleepycat.client.SDatabaseConfig

      `getAllowCreate, getBlobThreshold, getBtreeComparator, getBtreeMinKey, getBtreeRecordNumbers, getChecksum, getExclusiveCreate, getHashFillFactor, getHashNumElements, getHeapRegionSize, getHeapsize, getMultiversion, getNoWaitDbExclusiveLock, getPageSize, getPriority, getQueueExtentSize, getReadOnly, getReadUncommitted, getRecordLength, getRecordPad, getRenumbering, getReverseSplitOff, getSortedDuplicates, getTransactional, getTransactionNotDurable, getType, getUnsortedDuplicates, setAllowCreate, setBlobThreshold, setBtreeMinKey, setBtreeRecordNumbers, setChecksum, setExclusiveCreate, setHashFillFactor, setHashNumElements, setHeapRegionSize, setHeapsize, setMultiversion, setNoWaitDbExclusiveLock, setPageSize, setPriority, setQueueExtentSize, setReadOnly, setReadUncommitted, setRecordLength, setRecordPad, setRenumbering, setReverseSplitOff, setSortedDuplicates, setTransactionNotDurable, setType, setUnsortedDuplicates`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SSecondaryConfig

          public SSecondaryConfig()

      Creates an instance with the system's default settings.

  - ### Method Detail

    - #### cloneConfig

          public SSecondaryConfig cloneConfig()

      Description copied from class: `SDatabaseConfig`
      Create a deep copy of this configuration object.
      Overrides:
        `cloneConfig` in class `SDatabaseConfig`
      Returns:
        a deep copy of this configuration object

    - #### 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)`

    - #### setAllowPopulate

          public SSecondaryConfig 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, the population of the secondary will be done within the explicit or auto-commit transaction that is used to open the database.

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

    - #### getImmutableSecondaryKey

          public boolean getImmutableSecondaryKey()

      Return whether the secondary key is immutable.
      Returns:
        whether the secondary key is immutable
      See Also:
        `setImmutableSecondaryKey(boolean)`

    - #### setImmutableSecondaryKey

          public SSecondaryConfig setImmutableSecondaryKey(boolean immutableSecondaryKey)

      Specify whether the secondary key is immutable.

      Specifying that a secondary key is immutable can be used to optimize updates when the secondary key in a primary record will never be changed after that primary record is inserted.

      Be sure to set this property to true only if the secondary key in the primary record is never changed. If this rule is violated, the secondary index will become corrupted, that is, it will become out of sync with the primary.

      Parameters:
        `immutableSecondaryKey` - whether the secondary key is immutable
      Returns:
        this

    - #### getForeignKeyDatabase

          public SDatabase getForeignKeyDatabase()

      Return 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.client.SDatabase)`

    - #### setForeignKeyDatabase

          public SSecondaryConfig setForeignKeyDatabase(SDatabase foreignDb)

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

      The foreign database must not have duplicates allowed.

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

    - #### getForeignKeyDeleteAction

          public SForeignKeyDeleteAction getForeignKeyDeleteAction()

      Return 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.client.SForeignKeyDeleteAction)`

    - #### setForeignKeyDeleteAction

          public SSecondaryConfig setForeignKeyDeleteAction(SForeignKeyDeleteAction action)

      Specify 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:
        `action` - the action taken when a referenced record in the foreign key database is deleted.
      Returns:
        this
      See Also:
        `SForeignKeyDeleteAction`

    - #### getKeyCreator

          public SSecondaryKeyCreator getKeyCreator()

      Return the user-supplied object used for creating single-valued secondary keys.
      Returns:
        the user-supplied object used for creating single-valued secondary keys
      See Also:
        `setKeyCreator(com.sleepycat.client.SSecondaryKeyCreator)`

    - #### setKeyCreator

          public SSecondaryConfig setKeyCreator(SSecondaryKeyCreator keyCreator)

      Specify the user-supplied object used for creating single-valued secondary keys.

      Unless the primary database is read-only, a key creator is required when opening a secondary database. Either a SKeyCreator or SMultiKeyCreator must be specified, but both may not be specified.

      Parameters:
        `keyCreator` - the user-supplied object used for creating single-valued secondary keys.
      Returns:
        this

    - #### getMultiKeyCreator

          public SSecondaryMultiKeyCreator getMultiKeyCreator()

      Return the user-supplied object used for creating multi-valued secondary keys.
      Returns:
        the user-supplied object used for creating multi-valued secondary keys
      See Also:
        `setMultiKeyCreator(com.sleepycat.client.SSecondaryMultiKeyCreator)`

    - #### setMultiKeyCreator

          public void setMultiKeyCreator(SSecondaryMultiKeyCreator multiKeyCreator)

      Specify the user-supplied object used for creating multi-valued secondary keys.

      Unless the primary database is read-only, a key creator is required when opening a secondary database. Either a SKeyCreator or SMultiKeyCreator must be specified, but both may not be specified.

      Parameters:
        `multiKeyCreator` - the user-supplied object used for creating multi-valued secondary keys

    - #### getForeignKeyNullifier

          public SForeignKeyNullifier getForeignKeyNullifier()

      Returns the user-supplied object used for setting single-valued foreign keys to null.
      Returns:
        the user-supplied object used for setting single-valued foreign keys to null.
      See Also:
        `setForeignKeyNullifier(com.sleepycat.client.SForeignKeyNullifier)`

    - #### setForeignKeyNullifier

          public void setForeignKeyNullifier(SForeignKeyNullifier keyNullifier)

      Specifies the user-supplied object used for setting single-valued foreign keys to null.

      This method may not be used along with `setMultiKeyCreator(com.sleepycat.client.SSecondaryMultiKeyCreator)`. When using a multi-key creator, use `setForeignMultiKeyNullifier(com.sleepycat.client.SForeignMultiKeyNullifier)` instead.

      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.

      WARNING: Key nullifier instances are shared by multiple threads and key nullifier methods are called without any special synchronization. Therefore, key creators must be thread safe. In general no shared state should be used and any caching of computed values must be done with proper synchronization.

      Parameters:
        `keyNullifier` - the user-supplied object used for setting single-valued foreign keys to null.
      See Also:
        `SForeignKeyNullifier`, `SForeignKeyDeleteAction.NULLIFY`, `setForeignKeyDatabase(com.sleepycat.client.SDatabase)`

    - #### getForeignMultiKeyNullifier

          public SForeignMultiKeyNullifier getForeignMultiKeyNullifier()

      Returns the user-supplied object used for setting multi-valued foreign keys to null.
      Returns:
        the user-supplied object used for setting multi-valued foreign keys to null.
      See Also:
        `setForeignMultiKeyNullifier(com.sleepycat.client.SForeignMultiKeyNullifier)`

    - #### setForeignMultiKeyNullifier

          public void setForeignMultiKeyNullifier(SForeignMultiKeyNullifier multiKeyNullifier)

      Specifies the user-supplied object used for setting multi-valued 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.

      WARNING: Key nullifier instances are shared by multiple threads and key nullifier methods are called without any special synchronization. Therefore, key creators must be thread safe. In general no shared state should be used and any caching of computed values must be done with proper synchronization.

      Parameters:
        `multiKeyNullifier` - the user-supplied object used for setting multi-valued foreign keys to null.
      See Also:
        `SForeignMultiKeyNullifier`, `SForeignKeyDeleteAction.NULLIFY`, `setForeignKeyDatabase(com.sleepycat.client.SDatabase)`

    - #### getThriftObj

          protected T getThriftObj()

    - #### getField

          protected java.lang.Object getField(F field)
                                       throws java.lang.IllegalStateException

      Return the value set on a specified field. Throw IllegalStateException if the field is not set.
      Parameters:
        `field` - the field
      Returns:
        the field's value
      Throws:
        `java.lang.IllegalStateException` - if the field is not set

Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved.