Yeah, clear as mud is about where my understand is.
OK, so the finder really only returns the reference to the object (duh, this is how all
EJB's work). So now I have three clients all with reference to the same object. Let's say the entity has some int field called quantity, and these three clients all modify that field by adding to it or subtracting from it. To make this concrete, let's say quantity starts with the value of 7.
Each client gets a reference to the entity bean at the start of some method. The server returns the references and continues on its way. The entity bean itself is undisturbed (it may be persisted or activated or whatever--who cares, it hasn't been "used" yet).
Eventually, one of the clients, client A, invokes some method to alter the quantity, say, adds 2. Now quantity = 9. Client A wants to alter it again, but before it does, client B invokes the same method on the bean, and adds 3, so now quantity = 12. When client A invokes it again, to add 4, it's adding 12 + 4 and we get the correct value of 16, right?
So the locking is only done when particular methods are invoked?
--Mark