开发者

JDOQL Subquery count problems

I am having trouble with subquery counts with JDOQL (using DataNucleus). The following query

SELECT this.price
FROM com.mysema.query.jdo.test.domain.Product
WHERE (SELECT count(other)
FROM com.mysema.query.jdo.test.domain.Product other
WHERE other.price > this.price) > a1
PARAMETERS java.lang.Long a1

causes the Exception

javax.jdo.JDOUserException: Cannot perform operation ">" on SubqueryExpression "(SELECT COUNT("OTHER".PRODUCT_ID) FROM PRODUCT "OTHER" WHERE "OT开发者_开发百科HER".PRICE > THIS.PRICE)" and IntegerLiteral "?"
    at org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:390)
    at org.datanucleus.jdo.JDOQuery.executeWithArray(JDOQuery.java:321)

The following query works neither :

SELECT this.price
FROM com.mysema.query.jdo.test.domain.Product
WHERE !(SELECT other
FROM com.mysema.query.jdo.test.domain.Product other
WHERE other.price > this.price).isEmpty()

What is the proper way to make sure that a subquery result is not empty?


I got the problems fixed by upgrading from DataNucleus 2.0.4 to 2.1.2. The first query works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜