• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
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!!!
 
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!!!
 
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
 
Whip out those weird instruments of science and probe away! I think it's a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic