• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which method is called?

 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which method is called when the bean goes back into the pool, after an entity bean is deleted from the database?

My immediate answer was ejbREmove() but the more i read words like 'after' i get more confused
 
Balaji VR
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out HFE Chapter 6, question-16 (page number 371). Hope this would clarify your doubt.

Happy learning!
 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No No...see the Question has the following Scenario...

You go an delete the entity from the Database...that is a particular row..

there is a bean instance corresponding to the row...

will ejbRemove() be called on its own....because...if i go by Question 16...and the bean attempts to call an ejbLoad() it will throw an Exception..ObjectNotFound..because the object has been delted...

I could be wrong..only if i am reading the Question wrong...

Now tell me..
 
Balaji VR
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remember, the beans will get passivated (where ejbStore() gets called and data from bean gets persisted into DB and lock is released!) After that ONLY, you can go and play with DB in straight! Here there is no point of contact exists between BEAN & DB (beacause the bean is passivated and returned to pool!)

Is that makes sense!
 
Balaji VR
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if you are trying to delete the same entity bean (where just before calling remove, you did a direct delete!). YES! Here you will get a ObjectNotFoundException
 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But still the anwser of Question 16 wont fit here

The Question reads...which method is called after the entity bean is deleted?

if the question was "which method is called /may be called before deleting an entity bean..?"Bingo..we had a winner...

But since Entity bean was removed....so ejbActivate(),ejbLoad(), ejbRemove() have already been called, data has been deleted...Bean instance..is now in the pool...the Question reads ..now what?
 
Balaji Anand
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the answer is... "nothing is called" after it has been deleted.
before deletion ejbRemove() is called.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic