@SuppressWarnings("unchecked")
 public <RT> SearchResults<RT> listResults(Expression<RT> expr) {
   queryMixin.addToProjection(expr);
   Query countQuery = createQuery(true);
   countQuery.setUnique(true);
   countQuery.setResult("count(this)");
   long total = (Long) execute(countQuery);
   if (total > 0) {
     QueryModifiers modifiers = queryMixin.getMetadata().getModifiers();
     Query query = createQuery(false);
     reset();
     return new SearchResults<RT>((List<RT>) execute(query), modifiers, total);
   } else {
     reset();
     return SearchResults.emptyResults();
   }
 }
 public <RT> SearchResults<RT> listResults(Expression<RT> expr) {
   getQueryMixin().addToProjection(expr);
   Query countQuery = createQuery(toCountRowsString(), null, true);
   long total = (Long) countQuery.uniqueResult();
   try {
     if (total > 0) {
       QueryModifiers modifiers = getMetadata().getModifiers();
       String queryString = toQueryString();
       logQuery(queryString);
       Query query = createQuery(queryString, modifiers, false);
       @SuppressWarnings("unchecked")
       List<RT> list = query.list();
       return new SearchResults<RT>(list, modifiers, total);
     } else {
       return SearchResults.emptyResults();
     }
   } finally {
     reset();
   }
 }