I encountered following question from one of the mock tests
Which of the following methods brings a bean from "does not exist" to pooled state?
A. ejbCreate B. ejbLoad C. setEntityContext D. A call to any ejbHome<method> E. A call to any ejbFind<method>
It was not mentioned what type of bean this was so I picked up A. but the answer given by the mock test tool was C. To my knowledge C could be true only for Entity beans. I don't understand how this could fit for all the beans. Any takers? Am I missing something here.
ejbCreate is not true for all beans, for entity beans, ejbCreate is called when a user calls for a finder/Create method, container takes one bean FROM the POOL, then calls its ejbCrate method to make it the OO view of the required entity. IT's not called when the bean is created.
ejbLoad is obviously not correct.
ejbHome is a container callback for home biz method invocation; takes an existing bean out FROM pool.
ejbFind is obviously wrong too.
The only one being called just before the bean starts existing and goes to pool is getEntityContext. This is only for entity beans, it's true, but the question does not specify it must apply to any kind of bean. And anyway it's the only possible answer.
I know what you think. "About ajbCreate, this silly guy told me it was not true for all beans, but now he says the question does not specify it must be for all beans".
You're right, I'm silly, but I'm right. The difference is that the question DOES say that the method MUST takes a bean from DNE state to POOLED state. For the ejbCreate, it's true for some cases, but there is some cases where ejbCreate does NOT do what we want here : entity beans. So you cannot say ejbCreate method takes a bean from DNE to P, because sometimes it does not.
In the other hand, the setEntityContext may be used only for EB, but the point is you CANNOT find a case where setEntityContext does NOT takes an EB from DNE to P state.
I hope I'm clear. This is a question understanding problem, which in some cases is quite tricky. The only solution is to read carefully the question and think about its meaning.
[ March 29, 2006: Message edited by: Frederic Esnault ] [ March 29, 2006: Message edited by: Frederic Esnault ]
Thanks Frederic. Makes sense. You are right probably I will have to read more carefully. Well these are SUN exams, we shouldn't be surprised to see such tricky questions ;-) I have posted another question on Exceptions. Could you please check that out too ,if possible, I am sure that question also would have a similar explanation.
All the options relate to entity beans methods.(session beans have an ejbCreate() though). So I think we should look at all the options and come to a conclusion that they are asking in terms of "Entity Beans".
Just the other day, I was thinking ... about this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop