简体   繁体   中英

How can I get the result of a Count query in TopLink?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM