You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2006/02/17 13:34:34 UTC
[SOLVED] : Group by having causes "inner hasNext was false" error
Le 12 sept. 05 à 17:37, Bertrand Delacretaz a écrit :
> ...I'm using a GROUP BY HAVING query (using addGroupBy and
> setHavingCriteria to a QueryByCriteria), and depending on the data
> I get an "inner hasNext was false" error.
> IIUC the problem is due to the SELECT COUNT [2] query used by OJB
> to find out how many objects to retrieve, which in some cases finds
> more objects that the main query retrieves, causing the RsIterator
> to fail as it believes there are more objects to retrieve but finds
> the end of the result set...
I went back to this old problem, and fixed it simply by specifiying
that my MySQL driver is JDBC 3.0 capable, by adding
<jdbc-connection-descriptor ... jdbc-level="3.0">
in my ojb-repository.xml
Without this, OJB does a SELECT COUNT request to get the size of the
result set, and the generated SELECT was incorrect when my main query
includes a HAVING count(*) >= N clause.
Debugging the RsIterator class allowed me to see exactly what was
happening and fix my (stupid) mistake.
Just thought I'd send this info here so that others might be spared
the pain ;-)
-Bertrand