So I'm pretty new to using OpenJPA so this might be a simple fix...
I'm doing the following query.
select new com.bcbst.odstats.ejb.beans.RangeStats(count(a), avg(a.loadTime))
FROM ODUsage a
WHERE
a.accessDate BETWEEN :startDate AND :endDate and
a.loadTime is not NULL
I've noticed the following. If I remove the AVG aggregation function (and change the RangeStats constructor accordingly) it works fine in all cases.
The whole function is here.
http://aluink.pastebin.com/m49bbacb8The RangeStats class is here
http://aluink.pastebin.com/m54beb0dWhen I try to loop and do several queries I get this error.
http://aluink.pastebin.com/m164f3d96I've also noticed that if do the query just once with static :startDate and :endDate parameter values it works fine. If I run a loop over a date range which includes the static date previously used, it fails.
The end goal is to reproduce the following transact-sql query and have the values in somekind of bean. I really don't like the idea of doing multiple queries, but have yet to find a better solution. I'm open to idea.
SELECT count(*), avg(loadTime), month(accessDate)
FROM Table
WHERE
accessDate BETWEEN :startDate AND :endDate
GROUP BY month(accessDate)
TIA!