Re: no metadata set when using query chain with sql templates

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Jul 19 2006 - 18:38:46 EDT

  • Next message: Hannes Janetzek: "Re: no metadata set when using query chain with sql templates"

    BTW, I just patched QueryChain to return DataRows all the time and
    avoid doing object conversion at all:

    http://issues.apache.org/cayenne/browse/CAY-603

    Andrus

    On Jul 19, 2006, at 6:00 PM, Andrus Adamchik wrote:

    > Hi Hannes,
    >
    > Yeah, QueryChain can't handle object conversion, as Cayenne stack
    > only supports a single metadata object per query. I guess it can at
    > least use the entity of the first query in a chain, still making it
    > kind of kludgy. At the very minimum it should return "true" for
    > "isFetchingDataRows", so that no conversion occurs. I'll work on
    > fixing this, so thanks for pointing it out.
    >
    > Still I don't understand why you need to use a chain in your case.
    > If you want different sets of results for different query values,
    > just run separate SQLTemplates multiple times. Chain doesn't really
    > help you here.
    >
    > Andrus
    >
    >
    > On Jul 19, 2006, at 7:13 PM, Hannes Janetzek wrote:
    >
    >> Hello,
    >>
    >> I have a problem with using the queryChain. I could track down the
    >> error
    >> to the point, that the generic metadata has no data and so
    >> conversion fails. Thats where the null-pointer comes from.
    >>
    >> QueryChain query = new QueryChain();
    >> query.addQuery(new SQLTemplate(Bibtex.class, "select * FROM BIBTEX
    >> WHERE "+type[i]+" REGEXP \""+keyword+"\""));
    >> getDataContext().performQuery(query)
    >>
    >> The error-stack:
    >>
    >> WARN RequestProcessor: Unhandled Exception thrown: class
    >> java.lang.NullPointerException ERROR [action]: Servlet.service() for
    >> servlet action threw exception java.lang.NullPointerException
    >> at
    >> org.objectstyle.cayenne.access.ObjectResolver.init
    >> (ObjectResolver.java:102)
    >> at
    >> org.objectstyle.cayenne.access.ObjectResolver.<init>
    >> (ObjectResolver.java:93)
    >> at
    >> org.objectstyle.cayenne.access.DataDomainQueryAction.interceptObjectC
    >> onversion(DataDomainQueryAction.java:373)
    >> at
    >> org.objectstyle.cayenne.access.DataDomainQueryAction.execute
    >> (DataDomainQueryAction.java:151)
    >> at
    >> org.objectstyle.cayenne.access.DataDomain.onQuery(DataDomain.java:
    >> 766)
    >> at
    >> org.objectstyle.cayenne.util.ObjectContextQueryAction.runQuery
    >> (ObjectContextQueryAction.java:253)
    >> at
    >> org.objectstyle.cayenne.access.DataContextQueryAction.execute
    >> (DataContextQueryAction.java:90)
    >> at
    >> org.objectstyle.cayenne.access.DataContext.onQuery
    >> (DataContext.java:1422)
    >> at
    >> org.objectstyle.cayenne.access.DataContext.performQuery
    >> (DataContext.java:1411)
    >> at dbAccess.DBAccess.findBibtexByRegex(DBAccess.java:95)
    >>
    >>
    >>
    >> On the other hand this works well:
    >>
    >> SQLTemplate select = new SQLTemplate(Bibtex.class, "select *
    >> FROM BIBTEX WHERE "+type+" REGEXP \""+keyword+"\"");
    >> getDataContext().performQuery(select);
    >>
    >> The problem with this is that if have many items found more than once
    >> that I have to filter out then.
    >>
    >>
    >> Am I doing somethig wrong or this a known issue?
    >>
    >> Regards,
    >> Hannes Janetzek
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >>
    >
    >



    This archive was generated by hypermail 2.0.0 : Wed Jul 19 2006 - 18:39:10 EDT