db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Dietrick <rdietr...@sega.com>
Subject Re: insert dependencies during transactions
Date Thu, 17 Jul 2003 19:57:00 GMT
To answer my own question: the problem wasn't torque at all.  We had 
failed to set idMethod="none" for tables with 1:1 relationships with the 
user table, so that torque was generating its own primary key values and 
then the DB was complaining about unique constraint violations.

rdietrick@sega.com wrote:
> I'm trying to use transactions to manage a sequence of
> insert/update statements, and I'm getting foreign key
> constraint violations on the later insert statements.  The
> sequence is something like this (excuse any syntactical
> errors, as I'm not copying and pasting):
> 
> Transaction trans = new Transaction();
> Connection conn = trans.begin(dbName);
> User = new User();
> // set user attributes...
> user.save(conn);
> UserInfo userInfo = new UserInfo();
> // set user info attributes
> user.addUserInfo(userInfo);
> user.save(conn);
> 
> 
> There is a foreign key constraint which links
> user_info.user_id to user.user_id.  I was under the impression
> that as long as I used the same connection for these
> sequential update statements, I could get away with the code
> above.  Clearly this is not the case, however, as I'm getting
> a TorqueException (unique constraint violation at the second
> user.save() call).  Is there a workaround for this?
> 
> Thanks.
> 
> -rob
> 
> ---------------------------------------------------------------------
> 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