Hi,
I've come across a bit of a problem. I'm not sure it's got anything to
do with ojb, it's more likely to be my sloppy coding!  However, the
problem only occurs if I proxy a particular reference.
I've got a type : Meeting (and interface IMeeting).
It has three subtypes: Appraisal, Review, and Synopsis. (ignore the
latter).
Their interfaces are similarly named by start with I.  The interfaces
inherit from IMeeting, and do the classes.
As a part of Review, I am trying to build a list of previous reviews,
and their originating Appraisal. This is done through Review's method
"IMeeting getPreviousMeeting()". (note it's proxied)

public List getPreviousMeetings() {
        try {
                ArrayList previousList = new ArrayList();
                IMeeting m = this;
                previousList.add((IReview) m);
                while (m.getType() == Meeting.REVIEW) {
                        IReview r = (IReview) m;
                        m = r.getPreviousMeeting();
                        if (m.getType() == Meeting.REVIEW) {
                                previousList.add((IReview) m);
                        }
                        else{
                                //previousList.add((IAppraisal) m);

                        }
                        System.out.println("adding");
                }
                return previousList;
        } catch (Exception ex) {
                System.out.println("adding review caused error");
                ex.printStackTrace();
                return new ArrayList();
        }
}


If I run the method as above, it works fine, but doesn't include the
original appraisal in the list.
If I uncomment the line with "//previousList.add((IAppraisal) m);" it
causes an error:

java.lang.ClassCastException
        at com.netcase.pdp.bo.Review.getPreviousMeetings(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav
a:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor
Impl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(PropertyUti
ls.java:1185)
        at
org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUti
ls.java:772)
        at
org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.jav
a:801)
        at
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:952)
        at
org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:277
)
        at org.apache.jsp.review_jsp._jspService(review_jsp.java:578)
       ..

The repository is set up as:
    <field-descriptor name="previousMeetingId"
column="previousMeetingId" jdbc-type="INTEGER"/>
    <reference-descriptor name="previousMeeting"
class-ref="com.netcase.pdp.bo.Meeting" proxy="true">
        <foreignkey field-ref="previousMeetingId"/>
    </reference-descriptor>

If I change to repository to proxy="false" to not proxy the object, it
works fine! (but this is a considerable performance implication as it
very rarely uses this reference).

Any help would be greatly appreciated!

Thanks,

Daniel Perry.



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

Reply via email to