persistence@glassfish.java.net

Re: Visibility of setter method for id field

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Thu, 05 Jul 2007 10:22:24 -0700

Another option would be to use a constructor that takes the id value, to
populate the id field (in addition to the default constructor), and do not have
a setter at all if you are using field-based access.

Regards,
-marina

Gordon Yorke wrote:
> That really depends on your application. If you are using sequencing only then setting the visibility to protected would be fine. Some applications however have natural Ids or Ids provided by the application in this case the setter method should be public.
> --Gordon
>
> -----Original Message-----
> From: Kem Elbrader [mailto:kem.elbrader_at_gmail.com]
> Sent: Tuesday, July 03, 2007 10:12 PM
> To: persistence_at_glassfish.dev.java.net
> Subject: Visibility of setter method for id field
>
>
> Should the setter method for the id field be protected?