Package org.springframework.dao

# Class DuplicateKeyException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.core.NestedRuntimeException
org.springframework.dao.DataAccessException
org.springframework.dao.NonTransientDataAccessException
org.springframework.dao.DataIntegrityViolationException
org.springframework.dao.DuplicateKeyException

All Implemented Interfaces:
  `Serializable`

public class DuplicateKeyException extends DataIntegrityViolationException
Exception thrown when an attempt to insert or update data results in violation of a primary key or unique constraint. Note that this is not necessarily a purely relational concept; unique primary keys are required by most database types.

Consider handling the general `DataIntegrityViolationException` instead, semantically including a wider range of constraint violations.

Author:
  Thomas Risberg
See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`DuplicateKeyException(String msg)`
Constructor for DuplicateKeyException.
`DuplicateKeyException(String msg, Throwable cause)`
Constructor for DuplicateKeyException.

## Method Summary

### Methods inherited from class org.springframework.core.NestedRuntimeException

`contains, getMostSpecificCause, getRootCause`

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

`addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, 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`

## Constructor Details

### DuplicateKeyException

public DuplicateKeyException(@Nullable String msg)
Constructor for DuplicateKeyException.

Parameters:
  `msg` - the detail message

### DuplicateKeyException

public DuplicateKeyException(@Nullable String msg, @Nullable Throwable cause)
Constructor for DuplicateKeyException.

Parameters:
  `msg` - the detail message
  `cause` - the root cause from the data access API in use