What happens when two users access an Entity Bean concurrently?

Shaun Childers

Taken from Enterprise JavaBeans by Richard Monson-Haefel, "EJB, by default, prohibits concurrent access to bean instances. In other words, several clients can be connected to one EJB object, but only one client thread can access the bean instance at a time. If, for example, one of the clients invokes a method on the EJB object, no other client can access that bean instance until the method invocation is complete."

So, to answer your question, two users will never access an Entity Bean concurrently.

If you wish to know more about this issue, I would suggest downloading and reading the white paper from Sun: http://java.sun.com/products/ejb/docs.html . Some entity beans may require loopback calls, where bean A is invoked, in turn invoking bean B, which then invokes a method call on bean A. This kind of concurrency is tricky and is best avoided.

As a side note, the use of 'synchronized' is not permitted in EJB. (You must leave all that up to the server.)