This week's book giveaway is in the Spring forum.
We're giving away four copies of Java Persistence with Spring Data and Hibernate and have Cătălin Tudose on-line!
See this thread for details.
Win a copy of Java Persistence with Spring Data and Hibernate this week in the Spring forum!
  • 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Entity Bean Questions from HFE

 
Ranch Hand
Posts: 452
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks arun got the answers.

Your are right Question 1 & 2 are really tricky
 
Men call me Jim. Women look past me to this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic