• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Entity bean instance accessible to multiple client

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
     
    Ranch Hand
    Posts: 1683
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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).
     
    reply
      Bookmark Topic Watch Topic
    • New Topic