Originally posted by vu lee:
One of the differences between session bean instance and entity bean instance is that the later can be accessed by multiple clients. If an entity bean instance involves in a transaction, ONLY one client can access the instance. This makes me confused.
Dear vu,
Both statements are true.
The
EJB 2.0 Specs in Section 10.5.10 (Concurrent access from multiple transactions), Page 187 says:
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.
The container typically uses one of the following implementation strategies to achieve proper synchronization. (These strategies are illustrative, not prescriptive.)
The container activates multiple instances of the entity bean, one for each transaction in which the entity object is being accessed. The transaction synchronization is performed by the underlying database during the accessor method calls performed by the business methods, and by the ejbLoad, ejbCreate<METHOD>, ejbStore, and ejbRemove methods.The container acquires exclusive access to the entity object�s state in the database. The container activates a single instance and serializes the access from multiple transactions to this instance.
Regards,
Share Knowledge to gain it.<br /> <br />SCJP 1.2, SCDJWS 1.4, SCWCD 1.4, SCBCD 1.3, ICAD