【问题标题】:JDOQL Subquery count problemsJDOQL 子查询计数问题
【发布时间】:2010-10-22 12:26:52
【问题描述】:

我在使用 JDOQL(使用 DataNucleus)时遇到子查询计数问题。以下查询

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

导致异常

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

以下查询均无效:

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()

确保子查询结果不为空的正确方法是什么?

【问题讨论】:

    标签: jdo jdoql


    【解决方案1】:

    我通过从 DataNucleus 2.0.4 升级到 2.1.2 解决了这些问题。第一个查询有效。

    【讨论】:

      猜你喜欢
      • 2011-07-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-17
      • 2015-06-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多