db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dimka <dmip...@gmail.com>
Subject Problem with auto-generated identifiers
Date Thu, 09 Jul 2009 18:12:01 GMT

I am using embedded derby driver 10.4.2.0 - (689064)  with hibernate
Every once in a while I'm seeing an exception like this:

"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
'SQL090709201522730' defined on 'MYTABLE' "

I haven't seen such problems up until I've started to use auto-generated
identifiers, like the one below:

<id name="id" column="EVENT_ID" type="long">
	<generator class="native">
	</generator>
</id>

Fraction of the schema looks like this:
CREATE TABLE MYTABLE(EVENT_ID BIGINT NOT NULL, .... PRIMARY KEY (EVENT_ID))
CREATE TABLE hibernate_unique_key ( next_hi INTEGER )
INSERT INTO  hibernate_unique_key VALUES ( 0 )

The exception is thrown sometimes, not all the time.. I can't figure out why
and when. 
This is the most frustrating thing.
Can anyone give me a direction of where to look?
Thanks in advance!
-- 
View this message in context: http://www.nabble.com/Problem-with-auto-generated-identifiers-tp24415040p24415040.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.


Mime
View raw message