Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Mock Question HFEJB page 368. Q5.

 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello fellow ranchers,

Legal declarations for ejbCreate methods. We are that the following is correct

public String ejbCreateAccount() throws javax.ejb.CreateException

but

public int ejbCreate() throws javax.ejb.CreateException

is wrong. I thought both were correct. We can use a primative as a key, can't we?

regards
Simon
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although the spec is not clear on this, it appears as if a Serializable class is needed. So, this would be valid:

public Integer ejbCreate() throws javax.ejb.CreateException

And your DD entry would read:

<prim-key-class>Integer</prim-key-class>

If the bean provider implicitly declares in the entity bean class the type of the PK to be int, then one presumes that the container makes the necessary conversion between primitive type and wrapper type.
 
Simon Ingram
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roger,

Yes, I guessed it may be something like that. Strange that the spec only says that it must be a legal value type in RMI-IIOP which includes primatives!
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!