persistence@glassfish.java.net

Re: Visibility of setter method for id field

From: Kem Elbrader <kem.elbrader_at_gmail.com>
Date: Thu, 5 Jul 2007 15:24:34 -0600

Is there a reason to set them as protected? Netbeans 6M10 warns that
it should be protected. I suspect that the warning is specific to
Hibernate. Is this true.

On 7/5/07, Marina Vatkina <Marina.Vatkina_at_sun.com> wrote:
> 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?
>