cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marek Šabo <ms...@buk.cvut.cz>
Subject Re: Dynamic SQL object query
Date Sun, 21 Nov 2010 16:18:51 GMT

>> SELECT #result('COUNT(id)' 'Long' 'count')
>> from User #chain('AND' 'WHERE') #chunk($userId) id = #bind($userId) #end #chunk($userName)
userInfo.name LIKE $userName #end #end
>> becuase of "userInfo.name" which is object-style. So my first question is whether
there is a way of accomplishing this with EJBQL so I don't have to work with joins there.
>
> Yeah, something like this should work:
>
> SELECT COUNT(a) FROM User a WHERE a.id = :userId AND a.userInfo.name like :userName
>
Hi,

I played around with this a little bit and I have encountered 2 problems:

1) When 'id' is not object-mapped ejbql complains about invalid path, I 
found only this
http://www.mail-archive.com/user@cayenne.apache.org/msg02992.html
and it seems to be a dead end. Foolish attempt prefixing with 'db:' 
didn't work.

2) I thought null parameters were supported from 3.0 on, I'm using 3.0.1 
and in the following ejbql query:

     "SELECT COUNT(u) FROM User u WHERE u.username like :usernam AND 
u.userInfo.name like :userName"
     eq.setParameter("userName", null);
     eq.setParameter("usernam", "msabo");

results in java.lang.ClassCastException: 
org.apache.cayenne.ejbql.parser.EJBQLPatternValue cannot be cast to 
org.apache.cayenne.ejbql.parser.EJBQLEquals

Regards,

-- 
Marek Šabo



Mime
View raw message