This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Accessor for PK Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Accessor for PK Class" Watch "Accessor for PK Class" New topic
Author

Accessor for PK Class

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
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.
Christian D. Th. Sellberg
Greenhorn

Joined: Apr 02, 2004
Posts: 10
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 public, and must have a public constructor with no parameters.

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

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 public, 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessor for PK Class
 
Similar Threads
part 1 mock exam questions
set accessor method for PK
prim-key-class
ejbCreate's return value(Entity Bean)
portability