2009 is pretty old. Yes, moving to new versions often breaks things. But, in the majority of cases, you can fix the breaks quickly, by reading the advice in the version history:
http://www.web4j.com/web4j/javadoc/hirondelle/web4j/doc-files/VersionHistory.htmlAt some point, you will likely benefit from moving to the latest web4j version, and working through all the breaks.
-------
If I remember correctly, you should be able to add a 'group-by' and 'having' with DynamicCriteria. I may be mistaken about that.
You should increase the logging, if necessary, to see the SQL statement before it gets sent to the server. Sometimes when you examine the whole SQL statement, you can see mistakes - items in the wrong sequence, for example.