永发信息网

关于hql语句,错误找不到,求指导

答案:2  悬赏:0  手机版
解决时间 2021-02-04 16:09
  • 提问者网友:疯孩纸
  • 2021-02-04 12:06
public List searchRepairDetails(String lineNo,
String year) {
Session session = sessionFactory.getCurrentSession();
StringBuilder hql = new StringBuilder();
hql.append("select new pointId,pointName,subStr(repairOffDate,1,6),sum(repairTime),avg(repairTime)");
hql.append("from FrameRepairInfo where lineNo = :lineNo and year = :subStr(repairOffDate,1,6)");
//year不是实体类里的字段,是从repairOffDate截取出来的年份
hql.append("group by pointId,pointName,subStr(repairOffDate,1,6)");
hql.append("order by pointId,pointName,subStr(repairOffDate,1,6)");
Query query = session.createQuery(hql.toString());
List list = query.list();
return list;
}
以上是我写的语句,但是一直报错,找不到原因,求指导
错误:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: expecting OPEN, found ',' near line 1, column 19 [select new pointId,pointName,subStr(repairOffDate,1,6),sum(repairTime),avg(repairTime)from cn.ghac.gmes.bizcom.model.FrameRepairInfo where lineNo = :lineNo and year = :subStr(repairOffDate,1,6)group by pointId,pointName,subStr(repairOffDate,1,6)order by pointId,pointName,subStr(repairOffDate,1,6)]
到底是哪里错了呢!
谢谢大家!
最佳答案
  • 五星知识达人网友:不想翻身的咸鱼
  • 2021-02-04 13:26
为什么是select new pointId,

你把new去掉试试
全部回答
  • 1楼网友:神的生死簿
  • 2021-02-04 14:45
hql:    from class where gradeid  = ?   这句hql和sql是没什么区别的..省去select.
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯