db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald McLean <dmclea...@gmail.com>
Subject Re: Problem with auto-generated identifiers
Date Thu, 09 Jul 2009 20:05:53 GMT
It seems that you would get that if you created a second object before
saving the first one. This could also happen if you had multiple
threads or multiple users accessing a server DB.

I would think that you would want to use "GENERATED ALWAYS AS
IDENTITY" for event_id rather than generating the key through

On Thu, Jul 9, 2009 at 2:12 PM, Dimka<dmiperl@gmail.com> wrote:
> I am using embedded derby driver - (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 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?
Family photographs are a critical legacy for
ourselves and our descendants. Protect that
legacy with a digital backup and recovery plan.

View raw message