• Post Reply Bookmark Topic Watch Topic
  • New Topic

Entity bean instance accessible to multiple client  RSS feed

 
vu lee
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nadeem Awad
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
     
    Roger Chung-Wee
    Ranch Hand
    Posts: 1683
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You are getting confused between an entity object (which can be accessed by multiple clients) and an entity bean instance (which cannot be accessed by multiple clients).
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!