Hibernate and JTA

Discussion in 'Java' started by TH Lim, Jul 10, 2003.

  1. TH Lim

    TH Lim Guest

    Hi,

    I am using JTA as my transaction demarcation in my servlet under Orion
    AppServer. MySQL is the database Orion is connected to. My code that
    forces a rollback looks like this,

    <code>
    utx.begin(); // UserTransaction.begin()
    // session is an instance of net.sf.hibernate.Session
    q = session.createQuery("from Account as acc order by
    acc.name");
    clients = q.list();
    for (Iterator clientIter = clients.iterator();
    clientIter.hasNext();) {
    Account acc = (Account) clientIter.next();
    acc.setBalance(acc.getBalance() - 500);
    session.update(acc);
    }

    utx.setRollbackOnly();
    clients = q.list();
    for (Iterator clientIter = clients.iterator();
    clientIter.hasNext();) {
    Account acc = (Account) clientIter.next();
    log(acc.getName() + " with balance " +
    acc.getBalance());
    }

    </code>

    I updated Account's balance to a new value and forced a rollback. So
    when I reread the balance, it should give me the previous value.
    Right? What have I done wrong here? It works with Hibernate own's
    transaction mechanism. Pls. advise.Thank you.
     
    TH Lim, Jul 10, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MetroFix
    Replies:
    1
    Views:
    1,100
    Lee Fesperman
    Sep 8, 2003
  2. Distrans
    Replies:
    0
    Views:
    613
    Distrans
    Jan 13, 2005
  3. Scott Balmos

    Right use for JTA transactions?

    Scott Balmos, Jun 4, 2005, in forum: Java
    Replies:
    6
    Views:
    4,021
    nitin_verma
    Mar 16, 2010
  4. muttley
    Replies:
    0
    Views:
    2,738
    muttley
    Oct 20, 2005
  5. Replies:
    1
    Views:
    592
    =?ISO-8859-1?Q?Arne_Vajh=F8j?=
    Mar 3, 2007
Loading...

Share This Page