Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

reg Prim key class

 
Ranch Hand
Posts: 333
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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.
 
What's a year in metric? Do you know this metric stuff tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic