int count = 0;
// Build the query to retrieve the object
ExpressionBuilder builder = new ExpressionBuilder();
ReportQuery query = new ReportQuery(builder);
query.setReferenceClass(referenceClass);
query.addCount();
query.setSelectionCriteria(expression);
// Execute the query
List results = (List) getSession().executeQuery(query);
if ((results != null) && (results.size() > 0)) {