Hibernate and JTA

T

TH Lim

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top