db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: Generate Always and SQLIntegrityConstraintViolationException
Date Tue, 22 Jan 2008 10:07:01 GMT
wbecker <wbecker@gmail.com> writes:

> I don't understand how this can be happening, but it is:
>
> I've created at a table:
>
> CREATE TABLE Foo (
>        id INT NOT NULL GENERATED ALWAYS AS IDENTITY(START WITH 1, INCREMENT
> BY 1)
>      , PRIMARY KEY (id)
> );
>
> This works fine and I have added some data to it by using:
>
> INSERT INTO Foo () VALUE (DEFAULT)
>
> This works fine for a bit, but eventually it stops working and tells me: 
> java.sql.SQLIntegrityConstraintViolationException: The statement was aborted
> because it would have caused a duplicate key value in a unique or primary
> key constraint or unique index identified by 'SQL080122133352260' defined on
> 'Foo'.
>
> How could I possibly have duplicate values if the only way I add to it is by
> using the above query in a PreparedStatement?
>
> Now, I have found a way around it, which seems very dodgy. I can just
> recreate the PreparedStatement and then run the insert again and it works. 
>
> Is this a bug, expected behaviour or am I doing something wrong?

This looks like a bug to me. It would be great if you could log a bug
report in JIRA (see http://db.apache.org/derby/DerbyBugGuidelines.html
for instructions) so that we can keep track of it.

Thanks,

-- 
Knut Anders

Mime
View raw message