UniqueConstraintException (Oracle - Berkeley DB Java Edition API)
Date: 2014-12-16

com.sleepycat.je

## Class UniqueConstraintException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.lang.RuntimeException
      - - com.sleepycat.je.DatabaseException
        - - com.sleepycat.je.OperationFailureException
          - - com.sleepycat.je.SecondaryReferenceException
            - - com.sleepycat.je.SecondaryConstraintException
              - - com.sleepycat.je.UniqueConstraintException

- All Implemented Interfaces:
    Serializable

      public class UniqueConstraintException
      extends SecondaryConstraintException

  Thrown when an attempt to write a primary database record would insert a secondary record with a duplicate key, for secondaries that represent one-to-one and one-to-many relationships.

  When using the base API (`com.sleepycat.je`), this can occur when a `SecondaryDatabase` is not configured to allow duplicate keys (which is the default, see `DatabaseConfig.setSortedDuplicates(boolean)`). This implies the use of a one-to-one or one-to-many relationship.

  When using the DPL (`com.sleepycat.persist`), this can occur when a `SecondaryKey` is defined with a `Relationship.ONE_TO_ONE` or `Relationship.ONE_TO_MANY` relationship.

  The `Transaction` handle is invalidated as a result of this exception.

  Since:
    4.0
  See Also:
    Special considerations for using Secondary Databases with and without Transactions, Serialized Form

- - ### Method Summary

    - ### Methods inherited from class com.sleepycat.je.SecondaryReferenceException

      `getPrimaryKey, getSecondaryDatabaseName, getSecondaryKey`

    - ### Methods inherited from class com.sleepycat.je.DatabaseException

      `getMessage`

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

      `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

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

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

Copyright (c) 2004, 2014 Oracle and/or its affiliates. All rights reserved.