Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

is it legal?

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot
 
Thanks tiny ad, for helping me escape the terrible comfort of this chair.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic