Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Primitive return type for an enitity bean callback method ejbCreate()?

 
Mansur Khan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can the return type of the entity bean callback method ejbCreate() be a primitive? Something like...

public int ejbCreate(String strData) throws CreateException{
.
.
return null;
}

My blind guess is no, when I consider 'return null;' in the CMP Bean's ejbCreate().

But if that is true, what about the auto-boxing feature of Java 1.5?

Thanks in Advance
 
Mansur Khan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The root cause of this doubt is the page 368, question 5 of HFEJB which says the above method is not a legal declaration.
 
Mansur Khan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then we need a relook into the following post on the saloon:

Let's call it Postmortem at the Saloon, what say?

http://www.coderanch.com/t/162756/java-EJB-SCBCD/certification/CMP-entity-bean-primary-key
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what say?

I say that I removed my previous post Because primary keys should be RMI-IIOP compliants. I can't see where it says that it must not be a primitive. So it should be ok. I wonder if returning "0" would fail ?
 
Mansur Khan
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I got the answer here:

[ UD: removed link to copyrighted material ]

Although primary keys can be primitive wrappers (Integer, Double, Long, etc.), primary keys cannot be primitive types (int, double, long, etc.); some of the semantics of EJB interfaces prohibit the use of primitives. For example, the EJBObject.getPrimaryKey() method returns an Object type, thus forcing primary keys to be Objects. As you learn more about the EJB, you'll discover other reasons that primitives can't be used for single-field keys.

[ August 03, 2007: Message edited by: Ulf Dittmer ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic