selectRelationshipObjects and addPrefetch results in classcastexception

From: Twan Kogels (twa..wansoft.com)
Date: Tue Nov 23 2004 - 16:06:11 EST

  • Next message: Williams, Beth: "RE: Parameters with SQLTemplate"

    Hello all,

    Is there a known problem when using "QueryUtils.selectRelationshipObjects"
    in combination with "addPrefetch"?

    Because i have a function which uses those 2 functions:
    =============
    public List findAllWithExp(GalleryCategory cat) {
        SelectQuery query = QueryUtils.selectRelationshipObjects(_context, cat,
    "galleries");
        query.addPrefetch("projecten");

        return _context.performQuery(query);
      }
    =============

    GalleryCategory (variable cat) has zero or more Gallery objects
    (many-to-many relationship). Those Gallery objects can be reached by the
    "galleries" relationship of GalleryCategory:
    =============
    SelectQuery query = QueryUtils.selectRelationshipObjects(_context, cat,
    "galleries");
    =============
    The above code return all Gallery objects of "cat" (a GalleryCategory).
    This works perfect.

    But when i add a prefetch to my selectquery i receive a classcastexception:
    =============
    java.lang.ClassCastException
            at
    org.objectstyle.cayenne.access.util.SelectObserver.partitionBySource(SelectObserver.java:253)
            at
    org.objectstyle.cayenne.access.util.SelectObserver$PrefetchTreeNode.resolveObjectTree(SelectObserver.java:432)
            at
    org.objectstyle.cayenne.access.util.SelectObserver$PrefetchTreeNode.resolveObjectTree(SelectObserver.java:398)
            at
    org.objectstyle.cayenne.access.util.SelectObserver.getResultsAsObjects(SelectObserver.java:201)
            at
    org.objectstyle.cayenne.access.DataContext.performQuery(DataContext.java:1624)
            at
    org.objectstyle.cayenne.access.DataContext.performQuery(DataContext.java:1485)
            at freesite.dao.DAOGalleryImpl.findAllWithExp(DAOGalleryImpl.java:55)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:324)
            at spin.Invocation.evaluate(Invocation.java:122)
            at spin.off.OffInvocation.access$000(OffInvocation.java:30)
            at spin.off.OffInvocation$1.run(OffInvocation.java:70)
            at java.lang.Thread.run(Thread.java:536)
    =============

    What i mean to do with the prefetch is to prefetch the "projecten"
    relationship of Gallery. Because Gallery has a relationship with zero or
    more Projects (many-to-many relationship). The name of this relationship is
    "projecten".
    =============
    query.addPrefetch("projecten");
    =============

    Best regards,
    Twan Kogels



    This archive was generated by hypermail 2.0.0 : Tue Nov 23 2004 - 16:01:50 EST