Cache Results not working with "count" query


I've got a project with datanucleus v6.0.0-release and in my properties file I've got configured with the following values:

As you can see I have the datanucleus.query.results.cached enabled
In my project I have the following code:

I'm calling the count procedure twice, and in the second call throws an error

And the line where the exception is thrown is this

As I could review in the sources the error happens in the class line 186

In this line the value of the nextElement is the result of the count query that is a Long value

In the class in line 294 is verifying if the result is Persistable to return an ObjectId but in this case it returns a null value.
Then the collection resultIds in the class is added to the cache the first time.
Then in the second time it throws an error.
Is there any way to avoid this without disabling the property datanucleus.query.results.cached ?

Join to automatically receive all group messages.