File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
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: 3211
    
    6
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://aspose.com/file-tools
 
subject: Can primary key have primitive values?