• 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
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

HFEJB, Page no 368, Question 5

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Can we not declare,

public int ejbCreate() throws javax.ejb.CreateException { }

in entity bean ?? Is this not a valid declaration ?

HFEJB says, it is wrong.
Pls advice.

Micheal.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ejbCreate method is called by the Container to create the bean and it should not return any thing and should be void. Think about it. Who would the method return an integer to ??

Saagar
 
Micheal Jacob
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sagar,

Return type should be void for session bean, but for entity bean, it should be PK.

And my question was related to entity bean.

Micheal.
 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont have the book with me now, but may be the reason it is invalid is because the return type should be the primary key class and not a primitive type??? So if the return type was Integer instead of int it would be valid then.
 
Saagar Kappa
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Michael my mistake, I had exactly the same question when I did the chapter. I replied ur question in haste, without checking taht it was an entity bean... Since it is mentioned that the primary key can be an integer or a string, i felt that teh choice was valid too, but that leaves the question whether they were talking about a wrapped Integer or a primitive int..

Neways, hope someone else can clear this up..

Saagar
 
Micheal Jacob
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ya, as you all say, i too think "int" is the trick here...

Anyway, thanks arun, sagar.

Micheal
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm only starting to study for SCBCD, so I'm not sure this will help.
But it is said that the prim-key-class element contains the fully-qualified name of an entity bean's primary key class. This should confirm what you are saying. Primitive types are not allowed. Wrapper classes should be used instead.
 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A simple way to reason out this : You need to return null from the ejbCreate () method of a CMP entity bean. You can't return null if the return type is a primitive. Hence the return type cannot be a primitive
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic