Cache Results not working with "count" query


edwin.chui@...
 

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 ForwardQueryResult.java 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 ApiAdapter.java 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 ForwardQueryResult.java 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 ?


Andy
 

As replied on Gitter,
Clearly caching results (persistable object ids) when you are not returning persistable objects makes no sense. Just turn off "results caching" when not returning persistable results

Result Caching is for candidate results and nothing else currently, as shown by the implementation. A "count" query is not for candidate results


edwin.chui@...
 

Is there a method I can call, when executing the count query, to avoid getting the result from cache???
I've tried with the method setIgnoreCache.



But it still getting the same error.
If you can help me please!


Andy
 
Edited

IgnoreCache is for the L1 cache, as per the JDO spec.

You simply don't use result caching on that query, i.e either don't enable it in the first place or set datanucleus.query.resultCacheType to none.