0

我有这个:

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
4

1 回答 1

1

query.setShouldReturnSingleValue(true);

Number 结果 = (Number) getTopLinkTemplate().executeQuery(query, true);

这是 EclipseLink JavaDocs 的链接:

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

道格

于 2011-04-29T13:59:19.920 回答