Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFEJB - Entity beans: question pag 365 exe: 12

 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
12 - which method called on a CMP bean is ALWAYS associated with a state change in the bean?

A - ejbLoad() - why can't it be ALWAYS associated with a state change?

B - ejbFind - OK, no changes!

C - ejbRemove() - OK, database entity has been removed and bean come back to pool!

D - ejbActivate() - why is this associated with a state changes?

E - unsetEntityContext() - OK, bean has been removed from the pool!

Tks so much ranchers!!!
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the easiest way to answer this question is to remember the entity bean lifecycle (not ready->pooled->ready and vice versa).

The ejbFind() is always in the pooled state and the ejbActivate() is from ready to pooled and thus it indicates a state change.

Hope that helps.
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Freddy, how are you?

Right..but did you mean that for all states different from POOLED are going to mean "change of state" ? "unsetEntityContext" as well?

Another question..what about ejbLoad?

Tks so much!!!
 
Aakash Parashar
Ranch Hand
Posts: 123
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
State Change
Pooled ==> unsetEntityContext ==> does not exist

No State Change
client ==> business method call on ejbObject ==> ejbLoad ==> container calls business method in bean ==> ejbStore

Here in the complete traversal the bean is in ready state.
 
Awishek sinha
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Felipe
Also
State Changed
Ready state-->(ejbPassivate()or ejbRemove())-->Pooled state
ejbLoad() happens before any business method call from the client so that the bean instance get synched with the entity in database so no change of state
calling an business method on already existing entity in dayabase will invoke ejbActivate() which assign the bean instance to the entity.
Let me know if it helps to clear your doubt..
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Awishek and Neo!!

OK, now i got it..!! I was just thinking aboout "DATA" state!

I dind�t think about states itself : NOT READY, POOLED AND READ STATE...

That�s fine now!!!

Tks so much guysss!! ;-)

Have a great weekend!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic