Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Entity bean question - HFEJB pag 363, exe: 5!

 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please can anyone advise?

Tks!!!
 
Gowher Naik
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gowher and Amol!!!

Ahhhh, got it!! no primitive types so!!

Tks so much!!!

Hugs []'s
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic