You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Andrus Adamchik <an...@objectstyle.org> on 2006/07/20 00:00:44 UTC
Re: no metadata set when using query chain with sql templates
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.interceptObjectCo
> nversion(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
>
>
>
>
>
>
>
>
Re: no metadata set when using query chain with sql templates
Posted by Andrus Adamchik <an...@objectstyle.org>.
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
>>
>>
>>
>>
>>
>>
>>
>>
>
>
Re: no metadata set when using query chain with sql templates
Posted by Andrus Adamchik <an...@objectstyle.org>.
On Jul 19, 2006, at 8:55 PM, Hannes Janetzek wrote:
> Ok, thanks. What I wanted was to search over different fields and to
> get one list of bibtex entrys. Now I found a solution by just putting
> everything in one sql statement.
Cool. Yeah, something like SQL "union" should work here.
Andrus
Re: no metadata set when using query chain with sql templates
Posted by Hannes Janetzek <je...@tzi.de>.
Am Wed, 19 Jul 2006 18:00:44 -0400
schrieb Andrus Adamchik <an...@objectstyle.org>:
> 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.
>
Ok, thanks. What I wanted was to search over different fields and to
get one list of bibtex entrys. Now I found a solution by just putting
everything in one sql statement.
Regards.
Hannes
> 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)
> >
> > Am I doing somethig wrong or this a known issue?
> >
> > Regards,
> > Hannes Janetzek
> >
> >
> >
> >
> >
> >
> >
> >