You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Bryan Pendleton (JIRA)" <ji...@apache.org> on 2015/08/15 22:10:46 UTC
[jira] [Commented] (DERBY-6773) Derby throws plain
SQLIntegrityConstraintViolationException
[ https://issues.apache.org/jira/browse/DERBY-6773?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14698427#comment-14698427 ]
Bryan Pendleton commented on DERBY-6773:
----------------------------------------
Not every integrity constraint violation is easily classified into an exception
with a table name and a constraint name. Here's an example:
create table pos1 (c1 int not null unique, c2 int not null primary key);
insert into pos1 (c1) values (null);
This generates:
ERROR 23502: Column 'C1' cannot accept a NULL value.
which has neither a constraint name, nor a table name.
I believe these are the current list of integrity constraint violations that
Derby will detect. I will have to do some research to figure out which ones
have table name + constraint name as their arguments, and which do not.
String INTEGRITY_VIOLATION_PREFIX="23";
String LANG_NULL_INTO_NON_NULL = "23502";
String LANG_DUPLICATE_KEY_CONSTRAINT = "23505";
String LANG_DEFERRED_DUPLICATE_KEY_CONSTRAINT_T = "23506.T.1";
String LANG_DEFERRED_DUPLICATE_KEY_CONSTRAINT_S = "23507.S.1";
String LANG_FK_VIOLATION = "23503";
String LANG_CHECK_CONSTRAINT_VIOLATED = "23513";
String LANG_DEFERRED_CHECK_CONSTRAINT_T = "23514.T.1";
String LANG_DEFERRED_CHECK_CONSTRAINT_S = "23515.S.1";
String LANG_DEFERRED_FK_CONSTRAINT_T = "23516.T.1";
String LANG_DEFERRED_FK_CONSTRAINT_S = "23517.S.1";
The constraint I mentioned at the start of this comment is LANG_NULL_INTO_NON_NULL.
> Derby throws plain SQLIntegrityConstraintViolationException
> -----------------------------------------------------------
>
> Key: DERBY-6773
> URL: https://issues.apache.org/jira/browse/DERBY-6773
> Project: Derby
> Issue Type: Improvement
> Components: JDBC
> Affects Versions: 10.10.2.0
> Environment: Windows 7 x86_64, Java 1.6.0.45
> Reporter: Jochen Wiedmann
> Assignee: Abhinav Gupta
> Priority: Minor
> Attachments: CallSuper.diff, DERBY6733Repro.java, SamePackage.diff, SharedException.diff, addToTestSuite.diff, ant -verbose build all.txt, generateOnClientDoesntWork.diff, subPart1.diff, subPart2.diff, switchArgs.diff
>
>
> If a unique constraint is violated by an insert statement, then Derby throws an SQLIntegrityConstraintViolationException. The error message contains, in particular, the constraint name and the table name.
> To distinguish between cases with various constraints, Derby should instead throw a subclass of SQLIntegrityConstraintViolationException, with methods like getConstraintName(), and getTableName().
> See also https://hibernate.atlassian.net/browse/HHH-9516.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)