• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need explanation

 
srinija kosaraju
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
 
Paul Maessen
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic