db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Keeney, Thomas" <Keen...@SEC.GOV>
Subject RE: How to creat a Transaction to add or delete muti-Table Data?
Date Tue, 05 Aug 2003 14:51:10 GMT
Michel,

This is just a guess, but did you catch the Exception when the transaction
fails and call Transaction.rollback() (or Transaction.safeRollback())?  Your
code might look like this:
		
            Connection conn = null;

            try {
              conn = Transaction.begin( FactextraoptionsPeer.DATABASE_NAME
);
              extraoptions.save(conn);
              contract.save(conn);
              Transaction.commit(conn);
		} catch (Exception e) {
              Transaction.safeRollback(conn);
              throw e;
            }

Perhaps it will work this way.  I'm suprised that it hasn't worked for you
since I've been using transactions in Torque successfully for quite
sometime.  What database are you using?

Tom

-----Original Message-----
From: Michel Beijlevelt / Lucka [mailto:mbe@lucka.nl]
Sent: Tuesday, August 05, 2003 3:29 AM
To: Apache Torque Users List
Subject: Re: How to creat a Transaction to add or delete muti-Table
Data?


Howdy Tom,

thank you so much for your reply.

I incorporated this into the application I'm currently developing but in 
the log I still don't see any transactional SQL statements. I introduced 
a failure to trigger a rollback but I didn't get the results I expected.

I'll create a testbed to sort this issue out shortly. Thanks again.

gr. Michel

Keeney, Thomas wrote:

>Michel,
>
>If you want transactions to work, you must pass the Connection you retrieve
>from the Transaction class as the save() method parameter.  Transaction
>support works fine in Torque 3.0, so I'm sure it's still good for 3.1.  I
>tested it myself by setting up an insert (save()) on two separate tables,
>using the same Connection object.  One of the tables had all the correct
>data, whereas I did not include a value in the second table where there was
>a non-nullable field.  This caused the insert on the second table to fail,
>and the insert on the first table rolled back.  Test it yourself.  Of
>course, you have to make sure your database supports transactions (eg MySQL
>with InnoDB).
>
>Tom
>
>-----Original Message-----
>From: Michel Beijlevelt / Lucka [mailto:mbe@lucka.nl]
>Sent: Monday, August 04, 2003 3:25 AM
>To: Apache Torque Users List
>Subject: Re: How to creat a Transaction to add or delete muti-Table
>Data?
>
>
>Howdy,
>
>I you search the archives, there's some information about transcations, 
>but very little actually. I did find something like this:
>
>            Connection conn = Transaction.begin( 
>FactextraoptionsPeer.DATABASE_NAME );
>                extraoptions.save();
>                contract.save();
>            Transaction.commit( conn );
>
>But I haven't seen any proof in the logs that the transactional 
>statements are actually generated, so I doubt if it really works.
>
>gr. Michel
>
>PS Transaction is from: import org.apache.torque.util.Transaction;
>
>sailorhero wrote:
>
>  
>
>>I use torque at MSSAL server.I want to create a Transcation to add or
>>    
>>
>delete multi-Table Data.
>  
>
>>How to create this Transaction?
>>Please give me a example .Thanks very much!
>>
>>
>>
>> 
>>
>>    
>>
>
>
>
>---------------------------------------------------------------------
>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