Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

question about EJB Object and EJB instance?  RSS feed

 
Robert Strong
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?
 
Roger Chung-Wee
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!