• 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

HFE p368 #5 question

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic