If X clients find the same entity bean, will there be X caches in the container?

Jon Thorarinsson

An Entity Bean represents data in a persistent storage like a database and it caches the data.
If X clients connect (via a findXXX method to the same Entity EJB, will there be X copies of the cache in the container or will the container serialize access to a single Entity EJB?

The answer could be found in the EJB 2.0 Specs:

10.5.10 - Concurrent access from multiple transactions

When writing the entity bean business methods, the Bean Provider does not have to worry about concurrent access from multiple transactions. The Bean Provider may assume that the container will ensure appropriate synchronization for entity objects that are accessed concurrently from multiple transactions.

Some containers do activate many instances, while others do prefer to serialize multiple access to one single instance.
By default, the latest version of WebLogic would create X instances.