Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Entity Bean Questions from HFE

 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
cheenu Dev
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
cheenu Dev
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey my first reason is wrong..
if you have remove the entity is removed..
i confused entity with stateless..sorry.
 
Prakash Dwivedi
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 452
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks arun got the answers.

Your are right Question 1 & 2 are really tricky
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic