db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wbecker <wbec...@gmail.com>
Subject Generate Always and SQLIntegrityConstraintViolationException
Date Tue, 22 Jan 2008 03:38:17 GMT

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?

Cheers,
Will
-- 
View this message in context: http://www.nabble.com/Generate-Always-and-SQLIntegrityConstraintViolationException-tp15012038p15012038.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Mime
View raw message