[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.rt.eclipselink] JPA - How to use AVG between Calendar dates

Hello,

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.

Example:
In my EJB entity bean called AddressProcess.java, here is a snippet of the code:
@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.

Thank you, Ken U.