File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Entity Bean Questions from HFE 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 "Entity Bean Questions from HFE" Watch "Entity Bean Questions from HFE" New topic
Author

Entity Bean Questions from HFE

Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
Hi following are four questions from HFE. Can anyone kindly verify whether my answers (in Italics) are correct?

The Client calls this method to tell the Container that the client is done using the bean's EJB object reference
remove

this method is called when the bean goes back to the pool, after an entity is deleted from the database:
unsetEntityContext

This method is called immediately after the baen's constructor runs
setEntityContext

This method is called on the bean when the bean is in the pool, and the client invokes a business method on the component interface
ejbActivate


Prakash Dwivedi (SCJP2, SCWCD, SCBCD)
"Failure is not when you fall down, Its only when you don't get up again"
cheenu Dev
Ranch Hand

Joined: Nov 13, 2005
Posts: 276
1. there is no such method.
you cant remove the entity bean.
its the container wish not the clients.
also the question here is about EJBOject reference.
2. wrong. only entity is deleted not entity bean instance.
i suppose ejbPassivate() is called.
3. absolutely right.
4. right.


cheenujunk@gmail.com
cheenu Dev
Ranch Hand

Joined: Nov 13, 2005
Posts: 276
hey my first reason is wrong..
if you have remove the entity is removed..
i confused entity with stateless..sorry.
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
Cheenu Thanks for the reply

if you have remove the entity is removed..

SO is my answer correct? Because the question is talking about bean's EJB object referencewhere as calling remove method will also delete the row from the database.

These questions are from Head First EJB page 323. So i presume that there is nothing wrong with the questions.


2. wrong. only entity is deleted not entity bean instance.
i suppose ejbPassivate() is called.

HFE page 321:
A Bean doing on ejbRemove() will not be passivated before going back to the pool.
Since it is mentioned in the question that the entity is deleted from the database so i guess ejbRemove() should be invoked?
[ August 15, 2006: Message edited by: Prakash Dwivedi ]
Arun Natarajan
Ranch Hand

Joined: Jul 21, 2006
Posts: 30
Both 1 and 2 are trick questions (see the answers to the sharpen your pencil; pdf's are available online, search this forum for links to it).
1. There is no method to tell the container you are done using an entuty bean.
2. ejbRemove is called before the entity is deleted from the database. and there is no method that is called after this happens.
Prakash Dwivedi
Ranch Hand

Joined: Sep 28, 2002
Posts: 452
Thanks arun got the answers.

Your are right Question 1 & 2 are really tricky
 
GeeCON Prague 2014
 
subject: Entity Bean Questions from HFE