Foreign key integrity constraints and Transactions

2004-11-22 Thread John Harris
I've got table A & table B, where B.childID is a foreign key to A.ID. This is 
running on the oracle backend.

The scenario is: I create a new A entity, torque correctly starts the 
transaction and acquires a new A.ID for the primary key. Then torque goes on to 
create a new row for B, putting in the correct value for B.childID.

However - when save() is called for B, I get an integrity constraint error 
saying the parent key does not exist. And so as you would expect, the whole 
transaction is rolled back. 

If it's within the same transaction call - shouldn't this work?

The only way I could make it work is to disable the foreign key constraint - 
I'm not comfortable with this solution. Is this working as designed?

-John

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Foreign key integrity constraints and Transactions

2004-11-22 Thread Thomas Fischer




Hi John,

did you look at the tutorial,especially step 4 ? There, you have the same
situation with the author & book tables. The examples run on oracle with
the generated constraints.
However, in the tutorial, a seperate transaction is used for each insert.
If you want to use the same transaction for several methods, see the FAQ at
the torque wiki, item 10. It does work on oracle (I use it myself).
http://wiki.apache.org/db-torque/FrequentlyAskedQuestions

   Thomas

"John Harris" <[EMAIL PROTECTED]> schrieb am 22.11.2004 00:03:01:

> I've got table A & table B, where B.childID is a foreign key to A.ID.
> This is running on the oracle backend.
>
> The scenario is: I create a new A entity, torque correctly starts the
> transaction and acquires a new A.ID for the primary key. Then torque
> goes on to create a new row for B, putting in the correct value for
> B.childID.
>
> However - when save() is called for B, I get an integrity constraint
> error saying the parent key does not exist. And so as you would expect,
> the whole transaction is rolled back.
>
> If it's within the same transaction call - shouldn't this work?
>
> The only way I could make it work is to disable the foreign key
> constraint - I'm not comfortable with this solution. Is this working as
> designed?
>
> -John
>
> John Harris
> Clinical Team Lead
> System Interface Team, IHC
> -
> Intermountain Health Care
> 4646 Lake Park Blvd., M/S S4W
> Salt Lake City, UT 84120
>
> Voc (801) 442-4431
> Fax (801) 442-6996
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Foreign key integrity constraints and Transactions

2004-11-21 Thread John Harris
I've got table A & table B, where B.childID is a foreign key to A.ID. 
This is running on the oracle backend.

The scenario is: I create a new A entity, torque correctly starts the 
transaction and acquires a new A.ID for the primary key. Then torque 
goes on to create a new row for B, putting in the correct value for
B.childID.

However - when save() is called for B, I get an integrity constraint 
error saying the parent key does not exist. And so as you would expect, 
the whole transaction is rolled back. 

If it's within the same transaction call - shouldn't this work?

The only way I could make it work is to disable the foreign key 
constraint - I'm not comfortable with this solution. Is this working as 
designed?

-John

John Harris
Clinical Team Lead
System Interface Team, IHC
-
Intermountain Health Care
4646 Lake Park Blvd., M/S S4W
Salt Lake City, UT 84120

Voc (801) 442-4431
Fax (801) 442-6996


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]