• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

HFE p368 #5 question

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
5. Which are legal declarations for a CMP bean's ejbCreate methods?
d. public int ejbCreate() throws javax.ejb.CreateException
The book has it marked as not a valid declaration. I think it is, isn't it just overloading the create by returning an int? Can't I have something like:
public int ejbCreate() {
this.pk = pkGenerator();
return this.pk;
}
 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Van,
As far as I have understood, the primary key need to be a class. So you can't use int for this.
See 10.6.13 for more details.
Don't forget also that you have to fill a <prim-key-class> element in the Deployment descriptor.
Regards,
Cyril.
 
Van Nguyen
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the reply cyril,
so you're saying
- public Integer ejbCreate() throws CreateException ... is legal
- public int ejbCreate() throws CreateExecption ... is not legal
I'll take a look at the spec. Thanks for your help.
-Van
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by cyril vidal:
Hi Van,
As far as I have understood, the primary key need to be a class. So you can't use int for this.
See 10.6.13 for more details.
Don't forget also that you have to fill a <prim-key-class> element in the Deployment descriptor.
Regards,
Cyril.


I agree with Cyril.Only Objects can be the primary key. Usually we use the wrapper classes. Note also, that the EJB API methods accept/return java.lang.Object type for the primary key
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic