Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

need explanation

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These questions are from HFE

1.which are legal declarations for a CMP bean's ejbCreate methods

A.public void ejbCreateBigCustomer() throws javax.ejb.CreateException

B.public String ejbCreateAccount() throws javax.ejb.CreateException

C.static String ejbCreate() throws javax.ejb.CreateException

D.public int ejbCreate() throws javax.ejb.CreateException

E.public final String ejbCreate() throws javax.ejb.CreateException


I know A,C,E cannot be the answers.But why D cannot be the answer.For entity beans ejbcreate method returns a PrimaryKey.int can also act as a primarykey.


2.which method(s) from the EntityContext interface can be invoked from with in the ejbCreate method?

A.getEJBHome()
B.getEJBObject()
C.getCallerPrincipal()
D.getUserTransaction()
E.setRollBackOnly()

MyAnswers:A,C,E
Answers according to HFE:A,B,C,E

My doubt is how can B be the answer.Is it legal to call getEJBObject() from ejbCreate() of an entity bean.
container is not aware of the primarykey until the ejbCreate() returns.Then how can it prepare an EJBObject for the client,and how can we call getEJBObject();

3.which method(s) run in the transaction context of the method that causes their invocation?

A.ejbLoad()
B.ejbRemove()
c.ejbSelect()
D.ejbActivate()
E.ejbPassivate()
F.setEntityContext()

HFE Answers:A,B,C.

can any one please give the reason behind it.

thanks in advance
srinija
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi srinija,

1. because the primary key must be a *class*, so int is not OK but Integer is

2. you are right, it is not legal to call getEJBObject() from within ejbCreate()

3. the question should have been: which methods run in an unspecified transaction context? Answer D,E, and F. For the others the spec defines the transaction context in which they must run.
 
I AM MIGHTY! Especially when I hold this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic