• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Coffee Cream on EB - Mistakes/Doubts #3

 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following question:

Which method(s) from the EntityContext interface can be invoked from within the ejbCreate method?

A. getEJBHome()

B. getEJBObject()

C. getCallerPrincipal()

D. getUserTransaction()

E. setRollbackOnly()

I've answered A, C, D - The HF book gave A, B, C, D
I've spent all afternoon in memorizing the various bean things entity beans can do in various moments of their lifecycle. I'm referring to HF, page 338 (Bean things you can do during entity creation - ejbCreate() )

It's clearly stated:

1) Get a reference to the Home interface
2) Query the container about client's security info
3) Do CMT-related things
4) Access the JNDI special environment
5) Access other bean's methods
6) Access other resource managers

So, following the book (and Valentin Crettaz' PDF, and goodsense), from ejbCreate you can't get a reference to your EJB[Local]Object...Unless...The answer was: oh yes, you can, but you would get an exception. Thank you very much. But then, you turn on HF, page 144 (the 'Bang' section, got it?) and it's written:


In EJB, there's can and there's can. ...as in "Can a session bean client call getPrimaryKey() on the EJB object stub? ...for the exam, the answer would be NO! In other words, just because something is legally exposed to the caller [...] if the specs say you can't, then you can't.



So, as a famous singer was singing, ...'What am I supposed to do?'
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you cant get EJBObject from ejbCreate.
The container creates the EJBObject after ejbCreate returns a valid primary key to the container, and this happens before ejbPostCreate.
 
No more fooling around. Read this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic