Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Entity bean primary class  RSS feed

 
ALaxmi Shankaran
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.
 
Roger Chung-Wee
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.
 
Frederico Melo
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!