I've got a problem where an object has a 1:1 relationship with the supertype of 
another object.  If i proxy the relationship, then i cannot cast the related object to 
it's actual type. (it throws a ClassCastException).

The code below is part of Review.  Review Implements the interface IReview.  IReview 
extends the interface IMeeting. IReview has a method getPreviousMeting() which returns 
an IMeeting (this is proxied in the repository.xml).  This IMeeting is an Meeting or a 
Review.  IMeeting has a method getType() which gives an integer denoting it's type.

What i think is happening is the previousMeeting is being retrieved and proxied as 
implementing IMeeting, but it is an Review, and as such should implement IReview.  
Setting proxy=false fixes the problem.
public List getPreviousMeetings() {
    try {
        ArrayList previousList = new ArrayList();
        IMeeting m = this;
        while (m.getType() == Meeting.REVIEW) {
            m = ((IReview) m).getPreviousMeeting();
            previousList.add(m);
        }
        return previousList;
    } catch (Exception ex) {
        ex.printStackTrace();
        return new ArrayList();
    }
}

Reply via email to