Norton,

I had this same problem. The code you are running into follows:

Object one, two;
try {
        one = cls.newInstance();
        two = cls.newInstance();
        try {
                if(!one.equals(two)) {
                        status = false;
                        fireSpecViolationEvent(entity, new
Section("9.2.9.b"));
                }
        } catch(NullPointerException e) {} // That's OK - the implementor
expected the fields to have values

        try {
                if(one.hashCode() != two.hashCode()) {
                        status = false;
                        fireSpecViolationEvent(entity, new
Section("9.2.9.c"));
                }
        } catch(NullPointerException e) {} // That's OK - the implementor
expected the fields to have values
} catch(IllegalAccessException e) {
        // other stuff......   

As you see your pk class needs to either throw a NullPointerException or
return a hash codes that are equal.  This is kind of lame, so I just have my
PK just throws a NullPointerException when equals or hashCode is called on
an uninitialized instance.

By the way, I think the _guid field must be public for CMP to work.

-dain

-----Original Message-----
From: Norton Lam [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 18, 2001 1:05 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [JBoss-user] Primary Key warnings


No...

The _guid property is private.  I've overridden the
toString() method to return a _guid.toString().

Thanx for the thought.

-----Original Message-----
From: Rafael Alves Chaves [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 18, 2001 10:20 AM
To: '[EMAIL PROTECTED]'
Subject: RE: [JBoss-user] Primary Key warnings


Norton,

    Your PK equals method:

public boolean equals(Object obj) {
    GUID compareTo = (GUID)obj;

    if (_guid.toString().equals(compareTo.toString())) {
      return(true);
    }

    return(false);
  }

The correct would be:
...
    if (_guid.toString().equals(compareTo._guid.toString())) {
...

 Correct?

    Rafael


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to