Consider an object hierarchy such as this with all levels mapped as
persistent:

[A] interface
||
[B] concrete
||
[C] concrete

B b = new B(1);
C c = new C(1);

Based on the Identity using the method you propose, b != c even thought
the PK matches and they are both A objects.  However, we can't simply
look at a single "top-level class" either since the object could
implement multiple persistent capable interfaces.  IMHO, I think the
solution has to compare all levels of the hierarchy and the PK to check
for equality.

-wally



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 22, 2003 9:50 AM
To: [EMAIL PROTECTED]
Subject: Potential Identity bug involving mulitple extents.


Posted on behalf of a co-worker:

I have just encountered a situation that I THINK is a bug in the
Identity object. The equals method compares the topLevelClass, and I
think it should be comparing the realClass.

I'll try to explain my situation, and I HOPE that I can do so clearly.

I have a class AB, which derives from abstract class A, and implements
interface B.   AB contains a collection of C objects, and the C objects
all
have a backreference that should point at the AB object but is declared
in the repository_user as a reference to B.

When the object tree gets loaded, AB loads and is cached with an
Identity based on A .  OJB loads it's collection of Cs and attempts to
resolve the backreference, but looks for one using and Identity based on
B, since that is how the repository_user.xml is written.  Unfortunately,
the cached AB object is keyed by an Identity based on B.

Now, when I talk about Identity objects above "based on x", it's because
the identity implements hashCode and equals using the "top-level class"
of one of the extents.  I  wonder why we really care about the top level
class when trying to identify an object. Any object could potentially
exist in any number of extents. If the objects real class matches, and
the pkValues are the same, isn't that sufficient (and more accurate than
the current
method) to identify the object instance?

Or am I missing something here? I plan to make these changes and test
the result, but thought that it would be a could idea to sound out the
list first since it seems like someone else would have run into this
before now.

Dave Derry


This message contains information from Equifax Inc. which may be
confidential and privileged.  If you are not an intended recipient,
please refrain from any disclosure, copying, distribution or use of this
information and note that such actions are prohibited.  If you have
received this transmission in error, please notify by e-mail
[EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to