You've implemented equals incorrectly. As a rule, I would suggest running
equals(this) anytime that you write equals. In this case, it would return false,
and you would have discovered your error.
I would suggest:
public boolean equals(Object other) {
If (other instanceof PrimaryKey) {
PrimaryKey pk = (PrimaryKey) other;
return uid.equals(pk.uid) && cid.equals(pk.cid);
} else {
return false;
}
}
-- Rob
Rob Woollen
Senior Software Engineer
BEA WebLogic
[EMAIL PROTECTED]
Alex Cachia wrote:
> 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);
> }
> }
>
> --------- 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".