Meaningless Drivel is fun!*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes HF Concept in Head First Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "HF Concept in Head First" Watch "HF Concept in Head First" New topic
Author

HF Concept in Head First

Rajeev Gupta
Greenhorn

Joined: Nov 28, 2001
Posts: 16
Hi All
I got some confusion while reading HF. Following are the points i am seeking some clarification:
1) In HFE i found that for every bean instance created by the container, there is a new context object created. is it right? That means bean context object is conceptually different from servlet context object()?
2) In HFE i found that when client calls a create method on entity bean. A new instance of the bean as well as context is created and these two objects are linked together. Next the context object as well as the EJBObject is associated with that particular primary key.
if this is the case, than what is the use of having a bean pool because bean is associated with one context object and this context object has one primary key. In this case bean is always associated with one entity in the database thus it can never serve a different client whose EJBObject has a different PK than this beans context.
3) Is there any way we can update the mass data like mass select i.e. Home Business method. I mean something like updateAll()? or we need to take individual ejbObject and update the relevant data?
Thanks in advance.
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
Hi Rajeev,
1) Right.
2) Wrong . When a client calls create() on the home interface of an entity bean, a new bean instance is *not* created (or not necessarily). In fact entity bean creation and entity bean instantiation are totally unrelated. You're right by saying that the context object is associated with the bean instance for its whole life. *BUT*, the context object is mutable, meaning that its state may change over the time, including the primary key.
3) With BMP beans, you'll do whatever you want by using JDBC. With CMP beans (but as I lack of EJB *real experience*, please correct if I am wrong), you'll have to loop through the collection of component interfaces returned by your ejbSelect*() method, and call setters on them.
Regards,
Phil.
[ January 05, 2004: Message edited by: Philippe Maquet ]
Rajeev Gupta
Greenhorn

Joined: Nov 28, 2001
Posts: 16
Thanks for your prompt reply
*BUT*, the context object is mutable, meaning that its state may change over the time, including the primary key.
Could you give me some resource from where i can verify this information?
Thanks
Philippe Maquet
Bartender

Joined: Jun 02, 2003
Posts: 1872
The EJB specs.
No kidding now, the javax.ejb.EntityContext API doc does confirm that (I put the boldface myself) :
The EntityContext interface provides an instance with access to the container-provided runtime context of an entity enterprise Bean instance. The container passes the EntityContext interface to an entity enterprise Bean instance after the instance has been created.
The EntityContext interface remains associated with the instance for the lifetime of the instance. Note that the information that the instance obtains using the EntityContext interface (such as the result of the getPrimaryKey() method) may change, as the container assigns the instance to different EJB objects during the instance's life cycle.

Regards,
Phil.
 
 
subject: HF Concept in Head First