• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HF Pg 333 Regarding the Primary Key Class

 
Sudhir V
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the properties list of the primary class it says that "the fields in the bean class must have public accessor methods". The EJB spec 10.8 wherein describes the properties of the primary key class does not list this property. Is it valid?
 
Thomas De Vos
stable boy
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not too sure what the book has written down.
But think about it, it is the container who will use your primary key class. If the properties that make up your primary key are not public available to the container how can the container access these properties?
Maybe there is a slight confusion what we mean with properties here! Example: You can uniquely identify a row in your database by 2 columns, let's say: firstname and lastname. This means that your primary key class will have 2 persistent fields firstname and lastname, we refer to them as properties.
It is not only the properties of the primary key class that has to be public accessible to the container but the whole class has to be defined as public and has to be serializable.
Hope this helps.
 
Sudhir V
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the book says "public accessor methods". I know that that fields have to be declared public but it is not mandatory that they have public accessor methods. i.e. if there is a field called lastname then it is not mandatory to have public string getlastname() method to access that field.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic