Ah... I understand now. 

The problem is that my GUID class, by definition, creates 
a new GUID for every call to the default constructor.  I 
use it to create unique IDs for newly created EJBs. 
Therefore, the below code could never be true.  Given 
that, I guess I'll just have to live with the warnings. 

I'm assuming I'm not violating the EJB spec by designing 
my PK class like this, am I?  I'll have to check into that. 

I was thinking that you guys (the JBoss developers) were 
checking for equals() and hashCode() this way due to 
the spec, but I guess there's no other way for you to 
check for the override of these methods generically. 

Thanx to everyone that tried to help. 

Norton 

P.S.  Dain, I'm using BMP for the moment...

-----Original Message-----
From: Dain Sundstrom
To: '[EMAIL PROTECTED]'
Sent: 5/18/01 1:44 PM
Subject: RE: [JBoss-user] Primary Key warnings

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


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

Reply via email to