This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Can primary key have primitive values? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Reply Bookmark "Can primary key have primitive values?" Watch "Can primary key have primitive values?" New topic
Author

Can primary key have primitive values?

Puneet Vashisht
Ranch Hand

Joined: Jul 30, 2005
Posts: 44
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

Joined: Nov 25, 2002
Posts: 89
Hi,

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

Micheal.
B.Sathish
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
you cannot return null from the ejbCreate() of a CMP bean if its return type is int, can you?
Mikalai Zaikin
Ranch Hand

Joined: Jun 04, 2002
Posts: 3099
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.


Free SCDJWS 5.0 Study Guide - SCDJWS 5.0 Quiz (How to get SCDJWS 5.0 Quiz)
Java Platform, Enterprise Edition 6 Web Services Developer Certified Expert Exam Study Guide and Quiz
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Can primary key have primitive values?
 
Similar Threads
If Pkey of EB is of primitive type then what's the return type of ejbCreate()
what happen when a table haven't Primary Key?
HFE Pg 368 ques 5
ques about primary key class
quick question on primary key