Win a copy of Getting started with Java on the Raspberry Pi this week in the Raspberry Pi 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Liutauras Vilda
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Piet Souris

Coffe Cream on EB - Mistakes/Doubt #2

 
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
You don't like waffles? Well, do you like this tiny ad?
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
reply
    Bookmark Topic Watch Topic
  • New Topic