Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can primary key have primitive values?

 
Puneet Vashisht
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guyz

With CMP enitity beans we have to assign a primary key. Now i can definitely store primitive values in the fields. Like i may have a field count and declare it int type. So question is that can i also make count as my primary key. Does it alwayz have to be a class, cant i use primitive values in it.

Thankz,
Puneet
 
Micheal Jacob
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

PK cannot be primitive type.
Anyway you can use wrapper classes.

Micheal.
 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you cannot return null from the ejbCreate() of a CMP bean if its return type is int, can you?
 
Mikalai Zaikin
Ranch Hand
Posts: 3364
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For container-managed persistence, a primary key class must meet the following requirements:

* The access control modifier of the class is public.
* All fields are declared as public.
* The fields are a subset of the bean's persistent fields.
* The class has a public default constructor.
* The class implements the hashCode() and equals(Object other) methods.
* The class is serializable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic