Skip to content

Commit a0be804

Browse files
committed
nice javadoc for ConstraintViolationException
1 parent 9069d72 commit a0be804

File tree

1 file changed

+37
-4
lines changed

1 file changed

+37
-4
lines changed

hibernate-core/src/main/java/org/hibernate/exception/ConstraintViolationException.java

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@
1111

1212
/**
1313
* A {@link JDBCException} indicating that the requested DML operation
14-
* resulted in violation of a defined integrity constraint.
14+
* resulted in violation of a defined data integrity constraint.
1515
*
1616
* @author Steve Ebersole
17+
*
18+
* @see jakarta.persistence.Column#unique
19+
* @see jakarta.persistence.Column#nullable
20+
* @see jakarta.persistence.Column#check
21+
* @see jakarta.persistence.JoinColumn#foreignKey
22+
* @see jakarta.persistence.Table#uniqueConstraints
23+
* @see jakarta.persistence.Table#check
24+
* @see jakarta.persistence.JoinTable#foreignKey
1725
*/
1826
public class ConstraintViolationException extends JDBCException {
1927

@@ -43,37 +51,62 @@ public ConstraintViolationException(String message, SQLException root, String sq
4351
/**
4452
* Returns the name of the violated constraint, if known.
4553
*
46-
* @return The name of the violated constraint, or null if not known.
54+
* @apiNote Some databases do not reliably report the name of
55+
* the constraint which was violated. Furthermore,
56+
* many constraints have system-generated names.
57+
*
58+
* @return The name of the violated constraint, or {@code null}
59+
* if the name is not known.
60+
*
61+
* @see jakarta.persistence.ForeignKey#name
62+
* @see jakarta.persistence.UniqueConstraint#name
63+
* @see jakarta.persistence.CheckConstraint#name
4764
*/
4865
public @Nullable String getConstraintName() {
4966
return constraintName;
5067
}
5168

5269
/**
53-
* Returns the kind of constraint that was violated.
70+
* Returns the {@linkplain ConstraintKind kind} of constraint
71+
* that was violated.
5472
*/
5573
public ConstraintKind getKind() {
5674
return kind;
5775
}
5876

5977
/**
60-
* Enumerates the kinds of constraint violation recognized by Hibernate.
78+
* Enumerates the kinds of integrity constraint violation recognized
79+
* by Hibernate.
6180
*/
6281
public enum ConstraintKind {
6382
/**
6483
* A {@code not null} constraint violation.
84+
*
85+
* @apiNote The {@linkplain #getConstraintName constraint name}
86+
* in this case is usually just the column name.
87+
*
88+
* @see jakarta.persistence.Column#nullable
6589
*/
6690
NOT_NULL,
6791
/**
6892
* A {@code unique} or {@code primary key} constraint violation.
93+
*
94+
* @see jakarta.persistence.Column#unique
95+
* @see jakarta.persistence.Table#uniqueConstraints
6996
*/
7097
UNIQUE,
7198
/**
7299
* A {@code foreign key} constraint violation.
100+
*
101+
* @see jakarta.persistence.JoinColumn#foreignKey
102+
* @see jakarta.persistence.JoinTable#foreignKey
73103
*/
74104
FOREIGN_KEY,
75105
/**
76106
* A {@code check} constraint violation.
107+
*
108+
* @see jakarta.persistence.Column#check
109+
* @see jakarta.persistence.Table#check
77110
*/
78111
CHECK,
79112
/**

0 commit comments

Comments
 (0)