Hi,

Now I am curious about hashCode() implementations like the wizard generated:

> >     public int hashCode()
> >     {
> >         try
> >         {
> >             long    crcKey = -1;
> >             java.io.ByteArrayOutputStream bos = new
> > java.io.ByteArrayOutputStream();
> >             java.io.ObjectOutputStream oos = new
> > java.io.ObjectOutputStream(bos);
> >             oos.writeObject(this);
> >             oos.flush();
> >             java.util.zip.Adler32 adl32 = new java.util.zip.Adler32();
> >             adl32.update(bos.toByteArray());
> >             crcKey = adl32.getValue();
> >             return (int)(crcKey ^ (crcKey >> 32));
> >         } catch (java.io.IOException ioEx)
> >         {
> >             return -1;
> >         }

Is there something in the spec disallowing private members in composite PKs?

I know spec [10.8.2 & 14.1.9.2] for CMP PKs says "All fields in the primary
key class must be declared as public." but I've always interpreted that as
meaning "all fields associated with cmp-fields....". Am I wrong?

So wouldn't the following (equally generic) code be better?

=====

private int hc = -1;
public int hashCode() {
    if (hc == -1) {
        // calculate hash code value here
        hc = .....
    }
    return hc;
}

=====

Regrds,
Peter

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to