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