db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlos Chávez <ccha...@agssa.net>
Subject Re: broker.getCount()
Date Thu, 09 Sep 2004 00:18:32 GMT

Carlos Chávez Escribio :-)
>
>  Hi to all,
>  i have the next code ("fac_estado_id" and "facNum" are Integer) :
>
>  Criteria crit1 = new Criteria();
>  crit1.addEqualTo("fac_num", facNum);
>
>  Criteria crit2 = new Criteria();
>  crit2.addEqualTo("max(fac_estado_id)", fac_estado_id);
>
>  ReportQueryByCriteria query = new
> ReportQueryByCriteria(Facturaestado.class, crit1);
>  query.setAttributes(new String[] { "fac_num" });
>  query.addGroupBy(new String[] { "fac_num" });
>  query.setHavingCriteria(crit2);
>  boolean hasRecord = broker.getCount(query) > 0;
>
>  Then the SQL of the code is:
>  SELECT count(*) FROM FACTURAESTADO A0 WHERE A0.FAC_NUM = ? GROUP BY
> A0.FAC_NUM
>
>  But i think that sql is wrong because do not have the having clause
>  (query.setHavingCriteria(crit2);) i think the correc is:
>
>  SELECT count(*) FROM FACTURAESTADO A0 WHERE A0.FAC_NUM = ? GROUP BY
> A0.FAC_NUM HAVING max(fac_estado_id) = ?

  sorry the correct sql is:

  SELECT count(*) FROM FACTURAESTADO A0 WHERE A0.FAC_NUM = ? GROUP BY
  A0.FAC_NUM HAVING MAX(A0.FAC_ESTADO_ID) = ?

  Cheers.
>
>  o something like that.
>
>  any idea ?
>
>  Cheers.
>
> --
> Carlos Chávez
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-dev-help@db.apache.org
>


-- 
Carlos Chávez

---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message