cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: Latest code snapshot breaks EJBQLQuery
Date Wed, 10 Dec 2008 06:02:04 GMT
Ok, this turned to be some stupid EJBQL spec limitation that we  
followed verbatim. Cayenne would not recognize a relationship path in  
a SELECT clause, so you'd need to define an id variable. I.e. your  
query may be rewritten like this:

   SELECT COUNT(a), b, b.attr FROM ObjName
   a INNER JOIN a.relationship b GROUP BY b, b.attr

I will work on fixing the limitation, but you can use the syntax above  
right away. Also I discovered (and fixed) the bug in GROUP BY clause  
that prevented mixing id variables and paths:

https://issues.apache.org/cayenne/browse/CAY-1144

Not sure if your hack repeating the last attribute twice was related  
to this bug or not, but now it works for me without any such hack.

Andrus



On Dec 5, 2008, at 4:18 PM, Andrus Adamchik wrote:

> Yeah, this part of the stack has undergone a major rework lately.  
> Although the fact that you had to use this workaround to begin with  
> is already suspect. Let me try this query out and see what's going on.
>
> Andrus
>
>
> On Dec 5, 2008, at 9:52 AM, Dave Dombrosky wrote:
>
>> A query that runs fine for me (with a strange workaround) in r721197,
>> is failing in the latest code from cayenne trunk (r723425 as of this
>> writing).  I am running it as an EJBQLQuery using
>> DataContext.performQuery(Query arg).
>>
>> The query looks something like the following "SELECT COUNT(a),
>> a.relationship, a.relationship.attr, a.relationship.attr FROM ObjName
>> a GROUP BY a.relationship, a.relationship.attr, a.relationship.attr".
>> With the older cayenne library, I had to get "a.relationship.attr" a
>> second time in the select and group lists, because cayenne was not
>> returning the final result column to me.  This was a decent  
>> workaround
>> for a while, but now this query won't even execute with the new
>> cayenne library!
>>
>> With the latest cayenne code, I am seeing the following error:
>>
>> Caused by: java.lang.ArrayIndexOutOfBoundsException: 3
>> 	at  
>> org 
>> .apache 
>> .cayenne.access.jdbc.ScalarRowReader.<init>(ScalarRowReader.java:40)
>> 	at  
>> org 
>> .apache 
>> .cayenne 
>> .access 
>> .jdbc.JDBCResultIterator.createRowReader(JDBCResultIterator.java:123)
>> 	at  
>> org 
>> .apache 
>> .cayenne 
>> .access.jdbc.JDBCResultIterator.<init>(JDBCResultIterator.java:83)
>> 	at  
>> org 
>> .apache 
>> .cayenne 
>> .access 
>> .jdbc.SQLTemplateAction.processSelectResult(SQLTemplateAction.java: 
>> 223)
>> 	at  
>> org 
>> .apache 
>> .cayenne 
>> .access.jdbc.SQLTemplateAction.execute(SQLTemplateAction.java:171)
>> 	at  
>> org 
>> .apache 
>> .cayenne 
>> .access.jdbc.SQLTemplateAction.performAction(SQLTemplateAction.java: 
>> 127)
>> 	at  
>> org 
>> .apache 
>> .cayenne.access.jdbc.EJBQLAction.performAction(EJBQLAction.java:101)
>> 	at  
>> org 
>> .apache 
>> .cayenne 
>> .access.DataNodeQueryAction.runQuery(DataNodeQueryAction.java:57)
>> 	at org.apache.cayenne.access.DataNode.performQueries(DataNode.java: 
>> 236)
>>
>> I tried removing some parts of the query, and it seems like I can run
>> the query if I remove the "a.relationship" part of it, but i need  
>> this
>> to get the PK of the referenced object.  Is there some way to
>> reference the DB Path of this instead of my current method?  It
>> doesn't seem like db path expressions are supported for EJBQLQuery
>> yet...
>>
>> -Dave
>>
>
>


Mime
View raw message