Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Entity bean primary class

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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.
 
That new kid is a freak. Show him this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic