You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by toto <en...@free.fr> on 2004/01/25 15:08:29 UTC

transactions

Hi,

 I'm trying to use transactions with torque but it does not seem to work...
here's roughtly what i wrote :

Connection con = null;
    try {
             con = Transaction.begin("mydb");
             o.setCredit(1000$);   // my torque data object
              ...  
              o.save();
              retval = callSomeChargeOperation(1000$, ...);
              if (retval < 0) Transaction.rollback(con);  
               else Transaction.commit(con);
    } catch (TorqueException te) {
            Transaction.rollback(con);
    }

The rollback does not work!
Changes have effectively been applied to the database when rollback() 
returns.
What's wrong? what should I write to make transactions work properly?

BTW, i'm running torque 3.0.2


thanks in advance,
enrico


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


RE: transactions

Posted by netseeker <ne...@manskes.de>.
Hi,

you have to use o.save(con) instead of o.save() otherwise your transaction
will not be used...


-----Original Message-----
From: toto [mailto:enrico.maccias@free.fr]
Sent: Sunday, January 25, 2004 3:08 PM
To: torque-user@db.apache.org
Subject: transactions


Hi,

 I'm trying to use transactions with torque but it does not seem to work...
here's roughtly what i wrote :

Connection con = null;
    try {
             con = Transaction.begin("mydb");
             o.setCredit(1000$);   // my torque data object
              ...
              o.save();
              retval = callSomeChargeOperation(1000$, ...);
              if (retval < 0) Transaction.rollback(con);
               else Transaction.commit(con);
    } catch (TorqueException te) {
            Transaction.rollback(con);
    }

The rollback does not work!
Changes have effectively been applied to the database when rollback()
returns.
What's wrong? what should I write to make transactions work properly?

BTW, i'm running torque 3.0.2


thanks in advance,
enrico


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

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08.01.2004

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.560 / Virus Database: 352 - Release Date: 08.01.2004


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