Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
None
Description
Hello!
When constraint violation exception occurs I need machine-readeble attributes of SQLIntegrityConstraintViolationException.
Here example how it works in PG:
if ( |
ex instanceof PSQLException pex && |
ex.getSQLState().startsWith("23") |
) {
|
return new ConstraintViolationException( |
null, |
pex.getServerErrorMessage().getSchema(), // <---- |
pex.getServerErrorMessage().getTable(), // <---- |
pex.getServerErrorMessage().getConstraint() // <---- |
);
|
}
|
For the reference:
ER_DUP_KEY 23000
eng "Can't write; duplicate key in table '%-.192s'"
ER_BAD_NULL_ERROR 23000
eng "Column '%-.192s' cannot be null"
ER_NON_UNIQ_ERROR 23000
eng "Column '%-.192s' in %-.192s is ambiguous"
ER_DUP_ENTRY 23000 S1009
eng "Duplicate entry '%-.192T' for key %d"
ER_DUP_UNIQUE 23000
eng "Can't write, because of unique constraint, to table '%-.192s'"
ER_NO_REFERENCED_ROW 23000
eng "Cannot add or update a child row: a foreign key constraint fails"
ER_ROW_IS_REFERENCED 23000
eng "Cannot delete or update a parent row: a foreign key constraint fails"
ER_ROW_IS_REFERENCED_2 23000
eng "Cannot delete or update a parent row: a foreign key constraint fails (%.192s)"
ER_NO_REFERENCED_ROW_2 23000
eng "Cannot add or update a child row: a foreign key constraint fails (%.192s)"
ER_DUP_ENTRY_WITH_KEY_NAME 23000 S1009
eng "Duplicate entry '%-.64T' for key '%-.192s'"
ER_FOREIGN_DUPLICATE_KEY_WITH_CHILD_INFO 23000 S1009
eng "Foreign key constraint for table '%.192s', record '%-.192s' would lead to a duplicate entry in table '%.192s', key '%.192s'"
ER_FOREIGN_DUPLICATE_KEY_WITHOUT_CHILD_INFO 23000 S1009
eng "Foreign key constraint for table '%.192s', record '%-.192s' would lead to a duplicate entry in a child table"
ER_DUP_UNKNOWN_IN_INDEX 23000
eng "Duplicate entry for key '%-.192s'"
ER_CONSTRAINT_FAILED 23000
eng "CONSTRAINT %`s failed for %`-.192s.%`-.192s"