I have med a very simple test project with simulated bank accounts and transaction (very similar to the example scenario in the transactions chapter in jboss4guide).
However, I have problems getting the transaction isolation as expected.
Since I can very easily get my client to break both the isolation (dirty read/write) and the consistency (total balance of accounts change)!
Here is the transfer() method in my session bean:
public Transaction transfer(
Account from_account = getAccount(from_account_id);
Account to_account = getAccount(to_account_id);
from_account.setBalance(from_account.getBalance() - amount);
to_account.setBalance(to_account.getBalance() + amount);
Transaction tr = new Transaction(from_account, to_account, amount, reference, comment);
} catch (InterruptedException e)
The sleep() I have done just to easily be able to create two overlapping transactions when I test.
I simply open two web windows towards the JSP client and run two overlapping transfers (with eg 10 seconds delay) and both go through with the result that the total balance of the accounts increase!
I must have missed something trivial? can the transaction handling be turned off by default?
I run MySQL 5.0, JBoss AS 4.0.5 GA (with default settings for EJB3) and all the tables are InnoDB tables.