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; }
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.
SCJP 1.4, SCWCD, SCBCD, IBM XML, IBM Websphere 285, IBM Websphere 287
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
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