Some queries may return a null row (see [#1134])
Example:
SELECT l FROM Server AS s JOIN Location AS l ON s.location_id = l.id
Such rows do not make sense. They should be excluded both from the count and from the result set.
Suggested implementation: tweak each and every query (excepted when fetching a unique object); for each selected class, add the criteria "AND <class>.id IS NOT NULL" (currently expressed in OQL as "ISNULL(<class>.id) != 1")