如何在 TopLink 中获取 Count 查询的结果?
我有这个:
ReportQuery query = new ReportQuery(OpenedFilesReport.class,
generateExpressionOpenedFilesReport());
query.addCount();
Object result = getTopLinkTemplate().executeQuery(query, true);
正如我所看到的,结果是一个 Vector,并且有一个 ReportQueryResult 类型的结果。那么有没有更聪明的方法来获得结果
((ReportQueryResult)((Vector)result).get(0)).getResults()//.. do additional class casts/getter calls
I have this:
ReportQuery query = new ReportQuery(OpenedFilesReport.class,
generateExpressionOpenedFilesReport());
query.addCount();
Object result = getTopLinkTemplate().executeQuery(query, true);
As I can see, the result is a Vector and has one result of the type ReportQueryResult. Is there a smarter way of getting the result then
((ReportQueryResult)((Vector)result).get(0)).getResults()//.. do additional class casts/getter calls
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
query.setShouldReturnSingleValue(true);
数字结果 = (Number) getTopLinkTemplate().executeQuery(query, true);
以下是 EclipseLink JavaDocs 的链接:
http://www.eclipse.org/eclipselink/api/2.2/org/eclipse/persistence/queries/ReportQuery.html#setShouldReturnSingleValue%28boolean%29
道格
query.setShouldReturnSingleValue(true);
Number result = (Number) getTopLinkTemplate().executeQuery(query, true);
Here is the link into the EclipseLink JavaDocs:
http://www.eclipse.org/eclipselink/api/2.2/org/eclipse/persistence/queries/ReportQuery.html#setShouldReturnSingleValue%28boolean%29
Doug