• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

reg Prim key class

 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it a must that the primary key class SHOULD define getter and setter methods for all variables declared??.
The spec (10.8.2) doesn't say anything !!!
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Giju,

I think that you replied to your own question by yourself:

The spec (10.8.2) doesn't say anything !!!



It means that it's not mandatory for sure. But as "All fields in the primary key class must be declared as public.", even in the case you'd provide getters and setters, the Container wouldn't use them: given the spec, the Container will access the fields directly, using reflection.

Regards,

Phil.
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For CMP, a primary key must be set by the end of ejbCreate() method. Although it is not required, the benefit of having the getter and setter methods to access a primiary is to allow bean provider to validate the primary key.
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joe,

I think your argument is questionable for design reasons (I mean that if you think of some business rules to be applied for validation, the persistence layer is not the right place). But it's not the point: you don't set the primary key yourself, the *Container* will do it for you. And as it won't call your setters anyway, any validation code you'd put in them would be useless by definition.

Regards,

Phil.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic