Re: selectRelationshipObjects and addPrefetch results in classcastexception

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Nov 23 2004 - 17:04:32 EST

  • Next message: Justin Deutsch: "Testing applications"

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

    Not known to me ;-) QueryUtils methods are mostly used for internal
    Cayenne tasks, so they are not tested with all possible usage scenarios.

    Can you run this in debugger to tell what class is actually returned?
    Default Java behavior of throwing ClassCastException without specifying
    what class caused it is not that helpful.

    Thanks
    Andrus

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



    This archive was generated by hypermail 2.0.0 : Tue Nov 23 2004 - 17:04:34 EST