db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Mahler <thm...@web.de>
Subject Re: [Identity] Serious question, when are two identity objects equal?
Date Thu, 10 Apr 2003 19:05:46 GMT
Hi Armin,

IMO this is closely related to the Identity across Extents discussion we 
had some time ago.

As a and b belong to the same extent (= topLevel class) and as they have 
the same PK value there Identities must be equal!

I assume that several testcases will fail if we change this semantics.

cheers,
Thomas


Armin Waibel wrote:
> 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
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
> 
> 


Mime
View raw message