|JPA - How to use AVG while computing Calendar date.time differences [message #387380]
||Sat, 25 April 2009 04:14
| Kenneth Unpingco
Registered: July 2009
I am new to EclipseLink and to JPA. I wanted to ask how should I use JPA's
AVG (average) for computing the average time total between two Calendar
objects (response.date.time subtracted to request.date.time)? The Calendar
dates are gotten from a Docstore table having a modDate column.
In my EJB entity bean called AddressProcess.java, here is a snippet of the
@NamedQuery(name = "AddressProcess.getAverageTimeForAddressesByDate",
query = "select AVG(res.modDate.time.time - req.modDate.time.time) from
AddressProcess as o JOIN o.requestDoc as req JOIN o.responseDoc as res
WHERE o.modDate BETWEEN :startDate AND :endDate")
I ran the program but I got a run-time exception error:
Exception Description: Syntax error parsing the query
[AddressProcess.getAverageTimeForAddressesByDate: select AVG(res.modDate -
req.modDate) from AddressProcess as o JOIN o.requestDoc as req JOIN
o.responseDoc as res WHERE o.modDate BETWEEN :startDate AND :endDate],
line 1, column 23: syntax error at [-].
Any recommendations/advice is greatly appreciated.
Powered by FUDForum
. Page generated in 0.04870 seconds