db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Fischer <fisc...@seitenbau.net>
Subject Re: unique constraint violation
Date Thu, 09 Mar 2006 08:08:56 GMT

Alex Chen <alex_chen@sbcglobal.net> schrieb am 08.03.2006 20:24:36:

> I have seem the following exceptions in my application:
>
> java.sql.SQLException: ORA-00001: unique constraint
> (DBUSER.USER_INFO_PK) violated
>
> It seems that the same primary key has been used again by the ID broker.

There have been a few messages in the past which seem to indicate that the
idbroker's thread safety might not be water-proof, but noone has been able
to pinpoint it yet. In normal circumstances, I'd suspect the same here, but
with the warning you gave below, I'm not so sure.

>
> When we use Torque to 'save' the object, the ID broker automatically
> allocates the primary key for that object, right?

Correct.

> I do not know what kind of scenario can cause the exception?
>
> When this happens, does ID broker try to reuse the same ID for the next
> insertion?  If so, wouldn't that make the exception happen indefinitely?

If this is really a thread safety issue, there is a good chance that
re-trying the insert would work.

>
> Another questions is that I also see the following warning message in my
> log:
> WARN  [main] IDBroker - IDBroker is being used with db 'payroll', which
> does not support transactions. IDBroker attempts to use transactions to
> limit the possibility of duplicate key generation.  Without
> transactions, duplicate key generation is possible if multiple JVMs are
> used or other means are used to write to the database.

That is a bit strange. The usual reason for this error is that you cannot
access the database. But given your message above, this clearly tells one
that you can connect. Is ist posible that you have defined more than one
database ?

>
> This may be something that causes the problem.  How do I let IDBroker
> know that my DB server support 'transaction'?
>  I am using Oracle and definitely it support transaction.

Torque just asks the database driver. The database driver knows whether the
database supports transactions or not. Maybe you are using an really old
driver ??? I am using Oracle's  9.2.0.4 driver,  and get no such messages.

By the way, is there any reason you are using the IdBroker ? For "normal"
purposes, the IdMethod "native" is the better choice in my opinion. I have
used the IdMethod "native" for years without any problems.

    Thomas


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Mime
View raw message