Пример #1
0
 /**
  * Verifica quantos registros existem de acordo com a entidade informada como parâmetro.
  *
  * @param exemplo - entidade que servirá como base de consulta.
  * @return o número de registros informados.
  */
 public int count(E exemplo) {
   ReportQuery rq = new ReportQuery();
   rq.setExampleObject(exemplo);
   rq.addCount();
   ReportQueryResult queryResult =
       (ReportQueryResult) getJpaEntityManager().createQuery(rq).getSingleResult();
   Number result = (Number) queryResult.getResults().get(0);
   return result.intValue();
 }
 public void verify() {
   super.verify();
   Iterator reportResults = ((Vector) results).iterator();
   while (reportResults.hasNext()) {
     ReportQueryResult result = (ReportQueryResult) reportResults.next();
     if (!((String) result.get("firstName")).startsWith("B")) {
       throw new TestErrorException("Incorrect Report Query result returned from the cache.");
     }
   }
 }
  public String getLastModifiedDate(Object sample) {
    String modifiedDate = null;

    ExpressionBuilder builder = new ExpressionBuilder(sample.getClass());
    ReportQuery report = new ReportQuery(sample.getClass(), builder);

    report.addMaximum("modifiedDate");

    jpa.getSession().executeQuery(report);

    List l = (List) jpa.getSession().executeQuery(report);

    if (l != null && l.size() > 0) {
      ReportQueryResult o = (ReportQueryResult) l.get(0);

      modifiedDate = (String) o.getByIndex(0);
    }

    return modifiedDate;
  }