Source code: org/hibernate/exception/ConstraintViolationException.java
1 // $Id: ConstraintViolationException.java,v 1.2 2004/11/21 00:11:27 pgmjsd Exp $
2 package org.hibernate.exception;
3
4 import org.hibernate.JDBCException;
5
6 import java.sql.SQLException;
7
8 /**
9 * Implementation of JDBCException indicating that the requested DML operation
10 * resulted in a violation of a defined integrity constraint.
11 *
12 * @author Steve Ebersole
13 */
14 public class ConstraintViolationException extends JDBCException {
15
16 private String constraintName;
17
18 public ConstraintViolationException(String message, SQLException root, String constraintName) {
19 super( message, root );
20 this.constraintName = constraintName;
21 }
22
23 public ConstraintViolationException(String message, SQLException root, String sql, String constraintName) {
24 super( message, root, sql );
25 this.constraintName = constraintName;
26 }
27
28 /**
29 * Returns the name of the violated constraint, if known.
30 *
31 * @return The name of the violated constraint, or null if not known.
32 */
33 public String getConstraintName() {
34 return constraintName;
35 }
36 }