|
11 | 11 |
|
12 | 12 | /** |
13 | 13 | * 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. |
15 | 15 | * |
16 | 16 | * @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 |
17 | 25 | */ |
18 | 26 | public class ConstraintViolationException extends JDBCException { |
19 | 27 |
|
@@ -43,37 +51,62 @@ public ConstraintViolationException(String message, SQLException root, String sq |
43 | 51 | /** |
44 | 52 | * Returns the name of the violated constraint, if known. |
45 | 53 | * |
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 |
47 | 64 | */ |
48 | 65 | public @Nullable String getConstraintName() { |
49 | 66 | return constraintName; |
50 | 67 | } |
51 | 68 |
|
52 | 69 | /** |
53 | | - * Returns the kind of constraint that was violated. |
| 70 | + * Returns the {@linkplain ConstraintKind kind} of constraint |
| 71 | + * that was violated. |
54 | 72 | */ |
55 | 73 | public ConstraintKind getKind() { |
56 | 74 | return kind; |
57 | 75 | } |
58 | 76 |
|
59 | 77 | /** |
60 | | - * Enumerates the kinds of constraint violation recognized by Hibernate. |
| 78 | + * Enumerates the kinds of integrity constraint violation recognized |
| 79 | + * by Hibernate. |
61 | 80 | */ |
62 | 81 | public enum ConstraintKind { |
63 | 82 | /** |
64 | 83 | * 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 |
65 | 89 | */ |
66 | 90 | NOT_NULL, |
67 | 91 | /** |
68 | 92 | * A {@code unique} or {@code primary key} constraint violation. |
| 93 | + * |
| 94 | + * @see jakarta.persistence.Column#unique |
| 95 | + * @see jakarta.persistence.Table#uniqueConstraints |
69 | 96 | */ |
70 | 97 | UNIQUE, |
71 | 98 | /** |
72 | 99 | * A {@code foreign key} constraint violation. |
| 100 | + * |
| 101 | + * @see jakarta.persistence.JoinColumn#foreignKey |
| 102 | + * @see jakarta.persistence.JoinTable#foreignKey |
73 | 103 | */ |
74 | 104 | FOREIGN_KEY, |
75 | 105 | /** |
76 | 106 | * A {@code check} constraint violation. |
| 107 | + * |
| 108 | + * @see jakarta.persistence.Column#check |
| 109 | + * @see jakarta.persistence.Table#check |
77 | 110 | */ |
78 | 111 | CHECK, |
79 | 112 | /** |
|
0 commit comments