我有这个:

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

最佳答案

query.setShouldReturnSingleValue(true);

数字结果=(数字)getTopLinkTemplate()。executeQuery(query,true);

这是EclipseLink JavaDocs的链接:

http://www.eclipse.org/eclipselink/api/2.2/org/eclipse/persistence/queries/ReportQuery.html#setShouldReturnSingleValue%28boolean%29

道格

10-08 18:32