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 broker.getCount()
Date Wed, 08 Sep 2004 23:59:13 GMT

 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) = ?

 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


Mime
View raw message