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
smime.p7s
Description: S/MIME cryptographic signature
