db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Armin Waibel" <ar...@code-au-lait.de>
Subject [Identity] Serious question, when are two identity objects equal?
Date Thu, 10 Apr 2003 17:53:06 GMT
Hi all,

do we have a bug in Identity or
in handling of the
setObjectsClass(Class objectsRealClass)
setObjectsRealClass(Class objectsRealClass)
methods?

public void testIdentityEquals()
    {
        int stamp = (int)(System.currentTimeMillis() %
Integer.MAX_VALUE);

        IdTestA a = new IdTestA(new Integer(stamp), "A_Test");
        IdTestB b = new IdTestB(new Integer(stamp), "B_Test");

        Identity oidA = new Identity(a, broker);
        Identity oidB = new Identity(b, broker);

        assertFalse(oidA.equals(oidB));
    }

Currently oidA and oidB are equals when IdTestA / IdTestB
extended from the same base class.
Because Identity does the following statement in the equals
method

result = this.getObjectsClass().equals(id.getObjectsClass());
// both objects have the same topLevel class---> true
instead of

result = this.getObjectsRealClass().equals(id.getObjectsRealClass());
// have differnent real classes ---> false

Think this could cause serious problems.
Any comments?

regards,
Armin


Mime
View raw message