KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > exception > ConstraintViolationException


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 JavaDoc;
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 JavaDoc constraintName;
17
18     public ConstraintViolationException(String JavaDoc message, SQLException JavaDoc root, String JavaDoc constraintName) {
19         super( message, root );
20         this.constraintName = constraintName;
21     }
22
23     public ConstraintViolationException(String JavaDoc message, SQLException JavaDoc root, String JavaDoc sql, String JavaDoc 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 JavaDoc getConstraintName() {
34         return constraintName;
35     }
36 }
37
Popular Tags