db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Matz <oliver.m...@ppi.de>
Subject [OJB] Issue #OJB178 - "Incorrect field reference" when first extent class is not c...
Date Wed, 11 Jun 2003 15:56:42 GMT
You can view the issue detail at the following URL:

Type :        Defect
Issue Id :    OJB178
Reported by: Oliver Matz
             oliverm - (oliver.matz@ppi.de)


Platform: All
Operating system: windows 2000
Summary: "Incorrect field reference" when first extent class is not concrete
Description: Suppose you have an extent class whose first class has itsself extent classes,
for example:

<class-descriptor class="A">
  <extent-class class-ref="B"/>
  <extent-class class-ref="C"/>

<class-descriptor class="B">
  <extent-class class-ref="D"/>
  <extent-class class-ref="E"/>

Now suppose you have a class X with a reference of to class A.  Then retrieving an instance
of class X will lead
to the following exception:

org.apache.ojb.broker.OJBRuntimeException: Incorrect field reference "y_refid" in org.apache.ojb.broker.metadata.CollectionDescriptor@192a848[cascade
delete=false,cascade retrieve=true,cascade store=false,is lazy=false,class of Items=class
	at org.apache.ojb.broker.metadata.ObjectReferenceDescriptor.getForeignKeyFieldDescriptors(ObjectReferenceDescriptor.java:201)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.getFKQuery1toN(PersistenceBrokerImpl.java:2090)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.getFKQuery(PersistenceBrokerImpl.java:1122)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollection(PersistenceBrokerImpl.java:1070)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.retrieveCollections(PersistenceBrokerImpl.java:1184)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.getDBObject(PersistenceBrokerImpl.java:1580)
	at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByIdentity(PersistenceBrokerImpl.java:1683)
	at de.ppi.neuwerk.repman.ojb.NeuwerkPersistenceBroker.getObjectByIdentity(NeuwerkPersistenceBroker.java:67)

The reason is the obvious from the following code snippet
from ObjectReferenceDescriptor.getForeignKeyFieldDescriptors:
if (mif.isInterface())
 //exchange interface class descriptor with first concrete
 Vector extents = mif.getExtentClasses();
 Class firstConcreteClass = (Class) extents.get(0);
 mif = getClassDescriptor().getRepository().

This code snippet is supposed to replace ClassDescriptor
mif by some ClassDescriptor describing a concrete class
in the extent of mif.  But it does not work.  In the above example, iit replaces the ClassDescriptor
for A by the ClassDescriptor for B, which is itsself an extent.

A few lines later if the code mif.getFieldDescriptorByName(fk)
will then retun null, which causes the exception.

Similar suspicious code can be found in

The problem can be solved with the attached 
patch for ObjectReferenceDescriptor, but it might
be cleaner to move the method findFirstConcreteClass
to a different place a use it consequently.
Status: New

View raw message