DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to.
DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
When an empty result list is returned by a query, calling hasNext method on its iterator returns true. The problem will not manifest if DN is forced to evaluate result list eg. by calling makeTransient pm method.
The bug can be fixed in several places. As a quickfix for my current project, I've chosen a solution that requires the minimal amount of code changes (https://github.com/marcin1j/datanucleus-mongodb/commit/050cca852c2bdc854b896a28f1f80c7013ae9f3d). It involves calling MongoDB cursor's hasNext before adding CandidateClassResult, which may not be "lazy" enough. Therefore, it's probably desirable to implement a more sophisticated logic in QueryResultIterator, deferring database cursor's hasNext call until it's actually needed.