Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

HFEJB - Entity beans: question pag 365 exe: 12

 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!
 
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!
 
Ranch Hand
Posts: 123
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic