• 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

pg 323 "Sharpen your pencil"

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
setEntityContext()
unsetEntityContex()
ejbRemove()
ejbActivate()
ejbLoad()
ejbPassivate()
ejbStore()
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?
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
...no 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 ]
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok I found the answers here

still wondering about ejbRemove though ...
 
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Lionel,

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
 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi vishwa,
About you r statment :-


...no 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 ???
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
carlos,

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic