ConstraintViolationException

Exception thrown when a database operation violates a defined constraint (e.g., unique index, foreign key, check constraint).

This exception encapsulates details about the constraint violation, including the specific type of violation (reason), and optional metadata such as the schema, table, column, and constraint name involved in the error.

Parameters

sqlState

The SQL state code returned by the database.

serverErrorMessage

The original error message from the database server.

Constructors

Link copied to clipboard
constructor(reason: ConstraintViolationExceptionReason, sqlState: String, serverErrorMessage: ServerErrorMessage)

Properties

Link copied to clipboard
open val cause: Throwable?
Link copied to clipboard

The name of the column associated with the constraint violation, if available.

Link copied to clipboard

The specific name of the constraint that was violated, if available.

Link copied to clipboard

The primary error message the database raised.

Link copied to clipboard

Additional, human-readable details about the violation provided by the database. For a unique violation this is where the offending key and value appear.

Link copied to clipboard
open val message: String?
Link copied to clipboard

The context of the query that resulted in this exception, if applicable.

Link copied to clipboard

The specific type of constraint violation mapped from the database error.

Link copied to clipboard

The name of the schema containing the table where the violation occurred, if available.

Link copied to clipboard

The raw error message received from the database, if applicable.

Link copied to clipboard

The SQL state code associated with the error, if applicable.

Link copied to clipboard

The name of the table where the constraint violation occurred, if available.

Link copied to clipboard

The call stack the violation arose in, for one raised inside a trigger or function.

Functions

Link copied to clipboard

Finds the Octavius failure behind this throwable, if there is one.

Link copied to clipboard
open override fun getDetailedMessage(): String

Provides a detailed, human-readable description of the error.

Link copied to clipboard
open override fun toString(): String