Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Coffe Cream on EB - Mistakes/Doubt #2

 
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.
 
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.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic