• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

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

 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please can anyone advise?

Tks!!!
 
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi gowher and Amol!!!

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

Tks so much!!!

Hugs []'s
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic