| Author |
Entity bean question - HFEJB pag 363, exe: 5!
|
Steven Colley
Ranch Hand
Joined: Feb 18, 2005
Posts: 290
|
|
We do have the following question: Which are LEGAL declarations for a CMP beans's ejbCreate methods? (choose all that apply) 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. C - public final String ejbCreate() throws javax.ejb.CreateException. The book says that the correct answer is option B. My question is..why isn't the option D considered correct as well? Tks so much!!!
|
SCJP | SCWCD | SCBCD | SCWSD 5 | SCEA (I) 1.4 | SCEA 5 | IBM SOA 669
|
 |
Amol Nayak
Ranch Hand
Joined: Oct 26, 2006
Posts: 218
|
|
Must not be static. Spec says
The method name must have ejbCreate as its prefix. The method must be declared as public. The method must not be declared as final or static. The return type must be the entity bean�s primary key type
|
 |
Steven Colley
Ranch Hand
Joined: Feb 18, 2005
Posts: 290
|
|
Hi Amon, how are you?? Well..dind't understand..Are you talking about option C or D ? I'm talking about the option D. According to your note : The method name must have ejbCreate as its prefix. - ok, D option does have! The method must be declared as public. -It's . The method must not be declared as final or static. - It's not NEITHER FINAL nor STATIC. The return type must be the entity bean�s primary key type - int primitive type is fine. (is it fine?) Does it make sense??? Tks so much!!
|
 |
Steven Colley
Ranch Hand
Joined: Feb 18, 2005
Posts: 290
|
|
please can anyone advise? Tks!!!
|
 |
Gowher Naik
Ranch Hand
Joined: Feb 07, 2005
Posts: 643
|
|
ejbCreate() must return primarykey. primarykey can be either be class or it can be object type(like String,Integer etc) But it cannot be primitive(like int) Now public int ejbCreate() throws javax.ejb.CreateException. returns int which i think is Wrong.
|
 |
Amol Nayak
Ranch Hand
Joined: Oct 26, 2006
Posts: 218
|
|
Whoops misread the question in hurry gowher is right, the primary key field cannot be primitive it has to be a subclass of java.lang.Object. It need not be String or wrapper classes like Integer,Long.. you can define your own class as a primary key.
|
 |
Steven Colley
Ranch Hand
Joined: Feb 18, 2005
Posts: 290
|
|
Hi gowher and Amol!!! Ahhhh, got it!! no primitive types so!! Tks so much!!! Hugs []'s
|
 |
 |
|
|
subject: Entity bean question - HFEJB pag 363, exe: 5!
|
|
|