开发者

In what situations does Query.execute() return null in DataNucleus

I have not added anything to my Database yet, thus the following query should return a result of 0 by my reckoning.

    Query query = pm.newQuery(Password.class);
    query.setFilter("password == :passwordParam");
    query.setResult("count(password)");
    query.setResultClass(Integer.class);
    Integer result = (Integer)query.execute(password);
    System.out.println("Result: [" + result + "]");

It returns null

Neither the javadocs, nor the result docs, say anything about this method being able to return null. My guess is that I did something wrong.

http://db.apac开发者_运维技巧he.org/jdo/api20/apidocs/javax/jdo/Query.html#execute%28%29 http://www.datanucleus.org/products/accessplatform_2_2/jdo/jdoql_result.html


When I tried your code with DataNucleus I experienced a similar problem at first.

The bycode enhancer was not running. Once I enabled it the count became 0 has expected.

Perhaps you're having a similar problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜