DataNucleus 中 Query.execute() 在什么情况下返回 null
我尚未向数据库添加任何内容,因此根据我的计算,以下查询应返回 0 结果。
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 + "]");
它返回 null
javadoc 和结果文档都没有说明此方法能够返回 null。我的猜测是我做错了什么。
http://db.apache.org/jdo/api20/apidocs/javax/jdo/Query.html#execute%28%29 http://www.datanucleus.org/products/accessplatform_2_2/jdo/jdoql_result.html
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.apache.org/jdo/api20/apidocs/javax/jdo/Query.html#execute%28%29
http://www.datanucleus.org/products/accessplatform_2_2/jdo/jdoql_result.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我用 DataNucleus 尝试你的代码时,我首先遇到了类似的问题。
字节码增强器未运行。一旦我启用它,计数就变成了预期的 0。
也许你也有类似的问题。
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.