## org.hibernate.exception
Class ConstraintViolationException

    java.lang.Object
      java.lang.Throwable
          java.lang.Exception
              java.lang.RuntimeException
                  org.hibernate.HibernateException
                      org.hibernate.JDBCException
                          org.hibernate.exception.ConstraintViolationException

All Implemented Interfaces:
  Serializable

    public class ConstraintViolationException

extends JDBCException

Implementation of JDBCException indicating that the requested DML operation resulted in a violation of a defined integrity constraint.

Author:
  Steve Ebersole
See Also:
  Serialized Form

Constructor Summary
`ConstraintViolationException(String message, SQLException root, String constraintName)`
`ConstraintViolationException(String message, SQLException root, String sql, String constraintName)`

Method Summary
`String` `getConstraintName()` Returns the name of the violated constraint, if known.

Methods inherited from class org.hibernate.JDBCException
`getErrorCode, getSQL, getSQLException, getSQLState`

Methods inherited from class java.lang.Throwable
`fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### ConstraintViolationException

    public ConstraintViolationException(String message,
                                        SQLException root,
                                        String constraintName)

### ConstraintViolationException

    public ConstraintViolationException(String message,
                                        SQLException root,
                                        String sql,
                                        String constraintName)

Method Detail

### getConstraintName

    public String getConstraintName()

  Returns the name of the violated constraint, if known.

  Returns:
    The name of the violated constraint, or null if not known.

Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.