Forums Register Login

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

+Pie Number of slices to send: Send
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!!!
+Pie Number of slices to send: Send
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

 
+Pie Number of slices to send: Send
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!!
+Pie Number of slices to send: Send
please can anyone advise?

Tks!!!
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Hi gowher and Amol!!!

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

Tks so much!!!

Hugs []'s
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 781 times.
Similar Threads
Mock Exam HF EJB
need explanation
HFEJB Page 368, Q # 5
Mock Question HFEJB page 368. Q5.
Coffe Cream on EB - Mistakes/Doubt #2
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:22:17.