I know this doesn't solve your problem, but the
equals method should look like <see below>

-----Urspr�ngliche Nachricht-----
Von: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]Im Auftrag von Alex Cachia
Gesendet: Mittwoch, 03. Mai 2000 20:38
An: [EMAIL PROTECTED]
Betreff: Example Entity EJB Primary Key for EJB 1.1


Does this look like a valid Entity EJB Primary Key for EJB 1.1  Each time I
try
to create an entity with a key like this I get a NullPointerException.

If anyone has a valid (it's worked before) Entity EJB Primary Key for EJB
1.1
I'd appreciate the example code.

Regard,

Alex
--------- begin code ---------

import java.io.Serializable;

public class PrimaryKey implements Serializable {

  public String uid = null;
  public String cid = null;

  public PrimaryKey(String uk, String ck) {
    uid = new String(uk);
    cid = new String(ck);
  }

  public String toString() {
    return uid.toString();
  }

  public int hashCode() {
    return uid.hashCode();
  }

  public boolean equals(Object other) {
    return uid.equals(other);
  }

Use:

  public boolean equals(Object other) {
        if (other instanceof PrimaryKey)

                PrimaryKey pk = (PrimaryKey)other;
                return uid.equals(pk.uid) && cid.equals(pk.cid);
        } else {
                return super.equals(other);
        }
  }


}

--------- end code ---------

__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

===========================================================================
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".

===========================================================================
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