Re: SQLTemplate with addPrefetch?

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Aug 25 2004 - 09:41:01 EDT

  • Next message: Tore Halset: "Re: SQLTemplate with addPrefetch?"

    Twan,

    This is a bug in PrefetchHelper. As the fix was trivial (changing
    "readPropertyDirectly" to "readProperty"), I applied it, and there is
    no need to open a bug report. Fix should be included in tomorrow's
    nightly build.

    Andrus

    On Aug 25, 2004, at 5:42 AM, Twan Kogels wrote:

    > Hello all,
    >
    > I did some more research and discovered the following:
    > ===========
    > (in PrefetchHelper.java resolveToOneRelations() )
    > List oids = new ArrayList(nobjects);
    >
    > for (int i = 0; i < nobjects; i++) {
    > DataObject sourceObject = (DataObject) objects.get(i);
    > DataObject targetObject =
    > (DataObject)
    > sourceObject.readPropertyDirectly(relName);
    >
    > ObjectId oid = targetObject.getObjectId();
    > oids.add(oid);
    > }
    > ===========
    >
    > The "(DataObject) sourceObject.readPropertyDirectly(relName);" causes
    > the ClassCastException because the Object the readPropertyDirectly
    > returns is of type:
    > ===========
    > class org.objectstyle.cayenne.Fault$ToOneFault -
    > org.objectstyle.cayenne.Fault$ToOneFaul..779885
    > ===========
    >
    > Because Fault isn't a subclass (or implements interface) of DataObject
    > the casting generates a "ClassCastException".
    >
    > I'm currently using "cayenne-1.1B2".
    >
    > Cheers,
    > Twan



    This archive was generated by hypermail 2.0.0 : Wed Aug 25 2004 - 09:41:08 EDT