• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can primary key have primitive values?

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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

Micheal.
 
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you cannot return null from the ejbCreate() of a CMP bean if its return type is int, can you?
 
Bartender
Posts: 3908
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic