db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oliver.m...@ppi.de
Subject RE: Identity.realClass set to abstract class?!
Date Tue, 09 Sep 2003 09:08:20 GMT
Hello,

> -----Original Message-----
> From: Thomas Mahler [mailto:thma32@web.de]

> > Armin and I agreed that this is the intended meaning 
> > of these values:
> > 
> >>objectsTopLevelClass - the highest persistence-capable 
> >>   class or interface (in the inheritance hierarchy)
> >>   that the identified object is an instance of
> >>
> >>objectsRealClass - the concrete class of the object, 
> >>   or null if not known.

> > -- snip ---
> > Class topLevelClass = getBroker().getTopLevelClass(
> > 	getObjectReferenceDescriptor().getItemClass());
> > Class realClass = getObjectReferenceDescriptor().getItemClass();
> > // ...
> > id = new Identity(realClass, topLevelClass, fkValues);
> > -- snap ---
 
> I agree with you. the above code snippet could lead to different 
> Identies identifying the same object. So IMO it's clearly a bug.

I am not sure I understand.  What do you mean by "different"?
It is o.k. to have distinct instances, isn't it, as long as they
are "equals()" and have the same "hashcode()"?

Can you construct a scenario where this bug becomes observable?

If so, we should include that in the test suite.

I think this is very difficult because in the rest of 
OJB code, the field Identity.realClass seems to be treated more
or less like what I would like to call lowestKnownClass.

If we agree that this (as opposed to Armin's and my formulation)
is the intended meaning of that field, we should document it 
that way, and I will be happy, too.

Since I started this thread, I would like to explain how
I found this issue.

The scenario in which I encountered problems is certainly 
non-typical usage of OJB. I have overridden the method 
PersistenceBrokerImpl.getObjectByIdentity() in order to
set the realClass based on the primary key values. (This
is possible in my application because I have a particular
SequenceManager that codes the realClass into the primary key
value.  Clever, isn't it?)  I used to skip that setting
in case the realClass had been set before, but this I did
not always benefit from that trick.
Now I do that setting more often and it's fine.

Olli



---------------------------------------------------------------------
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