Class ConstraintViolationException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
jakarta.persistence.PersistenceException
org.hibernate.HibernateException
org.hibernate.JDBCException
org.hibernate.exception.ConstraintViolationException
- All Implemented Interfaces:
Serializable
A
JDBCException indicating that the requested DML operation
resulted in violation of a defined data integrity constraint.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumerates the kinds of integrity constraint violation recognized by Hibernate. -
Constructor Summary
ConstructorsConstructorDescriptionConstraintViolationException(String message, SQLException root, String constraintName) ConstraintViolationException(String message, SQLException root, String sql, String constraintName) ConstraintViolationException(String message, SQLException root, String sql, ConstraintViolationException.ConstraintKind kind, String constraintName) ConstraintViolationException(String message, SQLException root, ConstraintViolationException.ConstraintKind kind, String constraintName) -
Method Summary
Methods inherited from class JDBCException
getErrorCode, getErrorMessage, getSQL, getSQLException, getSQLStateMethods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
ConstraintViolationException
public ConstraintViolationException(String message, SQLException root, @Nullable String constraintName) -
ConstraintViolationException
public ConstraintViolationException(String message, SQLException root, String sql, @Nullable String constraintName) -
ConstraintViolationException
public ConstraintViolationException(String message, SQLException root, ConstraintViolationException.ConstraintKind kind, @Nullable String constraintName) -
ConstraintViolationException
public ConstraintViolationException(String message, SQLException root, String sql, ConstraintViolationException.ConstraintKind kind, @Nullable String constraintName)
-
-
Method Details
-
getConstraintName
Returns the name of the violated constraint, if known.- Returns:
- The name of the violated constraint, or
nullif the name is not known. - See Also:
- API Note:
- Some databases do not reliably report the name of the constraint which was violated. Furthermore, many constraints have system-generated names.
-
getKind
Returns the kind of constraint that was violated.
-