• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Coffe Cream on EB - Mistakes/Doubt #2

 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding the following question:

Which are legal declarations for a CMP bean's ejbCreate methods

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

E. public final String ejbCreate() throws javax.ejb.CreateException

I answered B and D - The book gave as correct only B.

The specs, chapter 9.8 say:

The Enterprise JavaBeans architecture allows a primary key class to be any class that is a legal Value
Type in RMI-IIOP, subject to the restrictions defined in Subsections 10.6.13 and 12.2.12.


The restrictions are related to the implementation of hashCode() and equals(). As far as I know, int is a RMI-IIOP legal value, as it's a primitive datatype, therefore Serializable and all the rest. So the signature for answer D should be correct.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note the key word in the spec:
The Enterprise JavaBeans architecture allows a primary key class to be any class that is a legal Value Type in RMI-IIOP, subject to the restrictions defined in Subsections 10.6.13 and 12.2.12.

As int is not a class, it is invalid. You'd have to use Integer instead.
 
alzamabar
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Roger Chung-Wee:
Note the key word in the spec:

As int is not a class, it is invalid. You'd have to use Integer instead.


Thanks, now I've got it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic