If I have two clients accessing the same entity bean at the same time and they change the enitity bean, I get bad data. Example account entity bean with a function that transfers money, by adding or subtracting a value from the balance field. If the balance = 40 and two clients at the same time subtract 20 the balance should be 0, however it is coming back 20. The deployment descriptor is set to have transactions required for all methods. I thought about synchronizing on the ejb before the method changes the balance field but what about in a cluster, where that wont work if both clients have ejb's from different servers representing the same database record? Any ideas?
I figured it out. There is no problem. Thread1 was started first and it's run method was entered first, but it didn't call the ejb method first, thread2 did. So it apperead that the ejb was not getting updated with the correct values but it is. Sorry.