我在执行查询时遇到错误。错误是:
org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:GROUP靠近第1行,第239行[SELECT j.orderDate,MAX(j.endTime),MIN(j.startTime)FROM fr.thelem.timesbatch .dao.entities.JobExecEntity j WHERE j.name =?0 AND TO_DATE(j.orderDate,'YYYYMMDD')>?1 AND TO_DATE(j.orderDate,'YYYYMMDD')
查询是:
Query query = this.em.createQuery(
"SELECT j.orderDate, MAX(j.endTime), MIN(j.startTime) "
+ "FROM JobExecEntity j "
+ "WHERE j.name=?0 "
+ "AND TO_DATE(j.orderDate,'YYYYMMDD')>?1 "
+ "AND TO_DATE(j.orderDate,'YYYYMMDD')<?2 "
+ "AND NOT j.id=0 ORDER BY j.startTime "
+ "GROUP BY j.orderDate")
.setParameter(0, nomChaine)
.setParameter(1, new Date(Long.parseLong(start)*1000))
.setParameter(2, new Date(Long.parseLong(end)*1000));
有什么想法吗?
答案 0 :(得分:1)
ORDER BY j.startTime
子句应该在GROUP BY j.orderDate
子句之后。