• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Entity bean primary class

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As in case of primitive type primary key attribute, there is no need to specify the seperate primary key class.
And we can specify that directly in the deployment descriptor ,
Then in that case what will the return type of the ejbCreate() method in the entity bean's class.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The return type can be anything except non-Serializable objects. So, suppose you have these two DD entries in the <entity> element:


Then ejbCreate() will return a PK of type int.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The primary key attribute of an EJB can't be a primitive type. You must use a wrapper(java.lang.Integer in this case) to substitute those primitives, as you need to provide a serializable class.

regards,

Fred
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The primary key type must be a legal Value Type in RMI-IIOP. My understanding is that a primitive is such a legal value.

Furthermore, you only need a (Serializable) primary key class where the primary key maps to multiple fields in the entity bean class. If you always had to have a primary key class, you would be compelled to convert a single key field into an object by wrapping it in your primary key class.
 
Frederico Melo
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
from EJB 2.1 specification:

"12.2.12 - Entity Bean's primary key class

The bean provider must specify a primary key class in the deployment descriptor
The class must provide suitable implementation of hashcode() and equals() methods to simplify the management of primary key to the container."

For me, primitives are not classes nor implement hashcode() and equals()..

if anyone can call 13.equals(12) or 25.hashcode() please tell me.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic