db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashley Hayes <ashley.ha...@macalla.com>
Subject RE: Transactions and saving - problems with commit
Date Thu, 18 Sep 2003 15:53:02 GMT
think you need to get a DB connection to do the saving with...

conn = Transaction.beginOptional("yourb DB name", true);

// then save with the conn object
contact.save(conn );
company.setContact(contact);
company.save(conn );


Transaction.commit(conn);

-----Original Message-----
From: Graham Leggett [mailto:minfrin@sharp.fm]
Sent: 18 September 2003 16:46
To: Turbine Torque Users List
Subject: Transactions and saving - problems with commit


Hi all,

I have two Torque generated objects, the first is linked to the second 
via a foreign key. When I save the objects, I do this:

contact.save();
company.setContact(contact);
company.save();

And this works fine - both objects are saved correctly, and as they are 
new objects, Torque handles their primary keys.

The trouble starts when the above three statements are saved in a 
transaction. On the "company.save()" an exception is thrown because the 
primary key for contact cannot be found in the database, and the 
transaction support kicks in, rolling everything back.

How do I get around this? It seems that supporting both primary keys and 
rollback at the same time is a catch-22 situation - any ideas what I am 
doing wrong?

Regards,
Graham
-- 
-----------------------------------------
minfrin@sharp.fm		"There's a moon
					over Bourbon Street
						tonight..."


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