• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ejbCreate()??

 
srikanthD reddy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..

Which of the following method declarations for a session bean class are valid?
Choices:
� A. public void ejbCreate(String name) throwsCreateException {}
� B. public void ejbCreateBigCart() throws CreateException{}
� C. public void ejbCreate(String name) {}
� D. public static void ejbCreateSmallCart() {}
� E. public final PKeyType ejbCreate() {}
� F. public PKeyType ejbCreateLargeAccount() {}

in the above question why option is c is not a valid one ...as far as i remember in the bean class an ejbCreate method may throw a create Exception but its not a must!!!

please clear the doubt!!

thanks
sri
 
Gopi Donthireddy
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
who says it is not valid?
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CreateException is not mandated by the EJB spec for a session bean class, although some EJB servers require this exception to be declared.
 
shanthisri mocherla
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Srikanth,
So the correct answers are a,b,c .Right???
just started the SCBCD preparation.

Thanks
shanthisri
 
srikanthD reddy
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yah shanthi... thats write ..even i feel that a,b,c are right ....but i came across this question somewhere i couldn't remember that says only a,b....ny how as most of them says its a,b,c ...my doubt is clarified ...

thanks a lot...

thanks
sri
 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something about the above thread was bothering me..so i decided to check it on an App Server

I used IBM Websphere 5.1

When you say, Session bean - you can mean Stateful or Stateless

When you say stateful - then out of the options given by you

� A. public void ejbCreate(String name) throwsCreateException {} Valid
� B. public void ejbCreateBigCart() throws CreateException{} Valid
� C. public void ejbCreate(String name) {} Valid
� D. public static void ejbCreateSmallCart() {} Not Valid(Using Static)
� E. public final PKeyType ejbCreate() {} Not Valid
� F. public PKeyType ejbCreateLargeAccount() {} Not Valid

When you say stateless the only acceptable scenario is ejbCreate() with no params.Any other option creates a violation of EJB 2.0:7.8 Check it out and do let me know if i am wrong
 
satheesh krishnaswamy
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public void ejbCreateBigCart() throws CreateException{} Valid

How is this Valid? Shall we have like this ejbCreateBigCart()? or is this a typo.I feel it should be ejbCreate(argument) in case of Stateful and ejbCreate() without arguments in case of Stateless S.B.

Please correct me if I am wrong.
 
Rahul Mishra
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As i said ..try it out...on an app server...the spec says multiple ejbCreate is supported.

Now since this worked i am assuming this means that all create methods which begin with the words ejbCreate*******() and so on so forth.

any Experts on this?
 
shri mon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess the ejbCreate.... methods should be of void return type
Correct me if i am wrong

Thanks,
Shrimon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic