Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

question about EJB Object and EJB instance?

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a little bit confusing about how EJB Object and EJB instance works on BEA Weblogic8.1.

for Stateless Session Bean, the create() method in home interface would return an EJB Object to the user. So, I assume here that each EJB Object for a Stateless Session Bean is associated with a user, is it correct?

but for Entity Bean, the Finder method in Home interface, would return a primary key or a collection of primary keys, which are then used to construct EJB Objects. So, each EJB Object for an Entity Bean is associated with a primary key. When two users try to access the same Entity Bean simultaneously, both of them would be coupled with the same EJB Object, and this EJB Object would be assocaited with two Bean Instances representing the same data, servicing those two users respectively. Is it right?
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

for Stateless Session Bean, the create() method in home interface would return an EJB Object to the user. So, I assume here that each EJB Object for a Stateless Session Bean is associated with a user, is it correct?


No. The client gets a stub to the EJBObject, which will typically exist before a user even logs in.

but for Entity Bean, the Finder method in Home interface, would return a primary key or a collection of primary keys, which are then used to construct EJB Objects. So, each EJB Object for an Entity Bean is associated with a primary key. When two users try to access the same Entity Bean simultaneously, both of them would be coupled with the same EJB Object, and this EJB Object would be assocaited with two Bean Instances representing the same data, servicing those two users respectively. Is it right?


This is a little tricky. Conceptually, an entity bean represents a particular entity in the DB, so there will be just one for the two users. But how many bean instances will there be at runtime? That's up to the container to decide. There could be one if the container were to serialize the user requests, two if the requests were multithreaded.
 
catch it before it slithers away! Oh wait, it's a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic