• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Accessor for PK Class

 
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I read many EJB books which all says PK class need to have getter methods for the PK fields that it contains. However, I searched thru the spec and could not find such requirement.

Can anyone point me to the right place in the spec which makes this requirement? I just scanned thru the few sections of the spec related the PK but could not find it. I just wonder if this info is hidden somewhere else.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Alec,

I can only find the following about PrimaryKey�s related to your question in the spec on page 203

---
10.8.2 Primary key that maps to multiple fields in the entity bean class
The primary key class must be coderanch, and must have a public constructor with no parameters.

All fields in the primary key class must be declared as coderanch.

The names of the fields in the primary key class must be a subset of the names of the container-managed fields.
(This allows the container to extract the primary key fields from an instance�s container-managed
fields, and vice versa.)
---

As I read it the bean provider does not have to supply setter and getters for the pk fields.
The only requirement is that the pk fields of the PrimaryKey class are public and that they match the names of container-managed persistent fields.

This also seems to be how the JBoss 4.0 developers have read the spec. JBoss does not expect getter and setters on primary keys. JBoss only verifies that the fields are coderanch, have matching names with the container-managed persistent fields and that the hashCode and equals are implemented correctly and it will throw a run time error if the PrimaryKey does not have a default constructor with no arguments.

Kind regards
Christian
 
reply
    Bookmark Topic Watch Topic
  • New Topic