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

is it legal?

 
George Fung
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public int ebjCreate () throws javax.ejb.CreateException?
It's a question from HFEJB. I think it's legal as "int" can be type of Primary key.
 
Nishant Verma
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
George

this is Illegal.

ejbCreate<METHOD>() returns null for CMP.

1. However, compiler should complain this. Can anybody verify this??

2. If 1. is not true then EJB container should never ever ever call this method.
 
Darien Cheung
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe primitives are not valid for primary-key classes.
 
George Fung
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe primitives are not valid for primary-key classes

If the type of field is integer in table, we should use class Interger as return type. Am i right?
 
Darien Cheung
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, wrapper classes (Integer, Boolean etc) are RMI-IIOP. You can also define your own primary key class but it must be serializable (amoung other requirements like public fields, etc.)
 
Nishant Verma
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Darien Cheung:
You can also define your own primary key class but it must be serializable


Implementing the interface Serializable should **NOT** be a necessary condition. Reference 10.8 EJB 2.0 specs.

However, let me know if anybody disagrees.
 
Darien Cheung
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Section 10.6.13 says the PK class must be legal RMI-IIOP which implies serializable. Also HFE book page 333 says PK class must be serializable and public.
 
Balaji Anand
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is illegal.
1. Primary key class should be serializable classes. so no primitives allowed. yes we can use wrapper classes.
2. the signature of the method must specify the primary key class(both BMP and CMP)
3. the actual return statement must return null though for CMP and the exact pk for BMP.
(This is to support inheritance. like if your CMP bean class extends from a BMP bean class(the signature of the method has the pk class and the return statement returns the pk))
hope this helps
 
George Fung
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic