db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Chen" <alex_c...@sbcglobal.net>
Subject RE: unique constraint violation
Date Fri, 10 Mar 2006 17:53:02 GMT
Thank you very much for the information, Thomas.
I will give it a try.

Alex

-----Original Message-----
From: Thomas Fischer [mailto:fischer@seitenbau.net] 
Sent: Thursday, March 09, 2006 11:55 PM
To: Apache Torque Users List
Subject: Re: unique constraint violation

Hi Alex,

I have no experience at all with Torque 3.0, so everything I say here is
true for Torque 3.1+ and might not be applicable for 3.0.
The IdMethod "native" is using the database's own mechanism for generating
ids (sequences in the case of oracle), but the IdBroker is a
Torque-specific mechanism based on a table, which works for all databases.
You specify it by setting the defaultIdMethod attribute to "native" in the
database tag of your schema.xml. Please check the  appropriate dtd to see
whether this is the case for oracle. Afterwards, you need to regenerate the
om classes and execute the sql script (at the very minimum the statements
which create the sequences).

    Thomas

Alex Chen <alex_chen@sbcglobal.net> schrieb am 10.03.2006 01:38:53:

> Thomas,
>    Thanks for the information.  I am using Torque 3.0 and the Oracle
> driver is downloaded from Oracle site, so I do not know why the message
> about transaction, either.
> I did not specifically configure Torque to use ID broker.
> How to configure Torque to use IdMethod 'native'?  What is the
> difference between the two?
>
> Is there document I can browse?
>
> Thanks for the help.
>
> Alex
>
>
> Thomas Fischer wrote:
>
> >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
> >
> >
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>


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




---------------------------------------------------------------------
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