File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes pg 323 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 "pg 323 "Sharpen your pencil"" Watch "pg 323 "Sharpen your pencil"" New topic

pg 323 "Sharpen your pencil"

carlos fernandez

Joined: Mar 30, 2004
Posts: 17
I seem to have lost my pencil sharpener . . .
The first question asks what EntityBean interface container callback method best answers the following question - "the client calls this method to tell the Container that he (the client) is done using the bean's EJB object reference".
the container callback choices are pretty limited, 7 in all:
And the only one exposed to the client in ejbRemove() (via the home and component interfaces remove()). My problem is that this method does far more than simply kill the EJB object and entity bean instance.
The "there are no Dumb Questions" section on page 357 goes on about how the container garbage collects the EJBObjects and beans they represent - which seems to be the clients real goal in this question.
Is the answer really ejbRemove()? Am i just having last minute exam paranoia?
Vishwa Kumba
Ranch Hand

Joined: Aug 27, 2003
Posts: 1066
Originally posted by carlos:
Is the answer really ejbRemove()?

NO. ......The correct answer is no such method exists for entity bean!... This question puzzled me also. Shamefully, I checked up the answers
Did you try the second question on the same page:323?
Which method is called when the bean goes back to the pool after an entity is deleted from the database?
Answer : ejbPassivate()?
ejbPassivate() is not called for an entity bean that has just been deleted by the client.(ejbRemove() method is called before the entity is deleted and ejbPassivate() is not called after the entity is deleted!)....So the correct answer is method is called when the entity bean goes back to the pool after the deletion!
EJBObject garbage collection is vendor-specific.
I think U are perfectly alright. Good Luck for the exam!
[ April 02, 2004: Message edited by: Vish Kumar ]
Lionel Orellana
Ranch Hand

Joined: Mar 19, 2004
Posts: 87
Shamefully I want to know where you checked the answers ... the book doesn't give you the answers to must of the "sharpen your pencil" ...

If the answer to question 2 here is "there's no such method" it means the ejbRemove is called BEFORE the entity is removed from the database ...

I know ejbLoad happens after the db call ...
I know ejbStore happens before the db call ..
I am guessing ejbRemove happens before the db call ... can anyone confirm this?
[ July 02, 2004: Message edited by: Lionel Orellana ]
Lionel Orellana
Ranch Hand

Joined: Mar 19, 2004
Posts: 87
Ok I found the answers here

still wondering about ejbRemove though ...
Alex Sharkoff
Ranch Hand

Joined: Apr 11, 2004
Posts: 209

Client calls remove() on comp interface -> Container invokes ejbRemove() on the bean -> Container deletes an entity from persistent store (eg, record from db)

That is what the spec says about ejbRemove(14.1.3)

The container invokes the ejbRemove() method on an entity bean instance with container-managed persistence in response to a client-invoked remove operation on the entity bean�s remote home or remote interface.
The entity Bean Provider can use the ejbRemove method to implement any actions that must be done before the entity object�s representation is removed from the database.
The container synchronizes the instance�s state before it invokes the ejbRemove method. This means that the state of the instance variables at the beginning of the ejbRemove method is the same as it would be at the beginning of a business method.
After ejbRemove returns, the container removes the entity object�s representation from the database.

Hope it helps

Alex (SCJP 1.4, SCBCD 1.3, SCWCD 1.4, SCJD 1.4)
Giju George
Ranch Hand

Joined: Jun 08, 2004
Posts: 333
Hi vishwa,
About you r statment :- method is called when the entity bean goes back to the pool after the deletion!

Well, my understanding was, when the client call ejbRemove(), the EJBOBject is destroyed and the bean instance still survives and goes back to the pool...
Is this right ???

SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCEA
Valentin Crettaz
Gold Digger

Joined: Aug 26, 2001
Posts: 7610

Welcome to Javaranch, a friendly place for Java greenhorns

Please change your displayed name to conform to JavaRanch's Naming Policy.

You may change your displayed name here.

Thank you

[Blog] [Blogroll] [My Reviews] My Linked In
I agree. Here's the link:
subject: pg 323 "Sharpen your pencil"
It's not a secret anymore!