Hibernate order by 查询问题

「已注销」 「已注销」 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
HQL语句:

StringBuffer sbHql = new StringBuffer("SELECT NEW Employee(e.fchrEmployeeId,e.fchrEmployeeCode,
e.fchrEmployeeName,e.fdtCreateTime,e.fchrParentId,e.fchrParentName,e.fchrParentDepartment,e.fintStatus,e.fchrEmployeeEmail,e.fchrEmployeePhone,e.fchrEmployeeAddr,e.fchrEmployeeType,e.fchrEmployeeBrithday,e.fchrEmergencyPerson,e.fchrEmergencyPhone,e.fbitFresh) FROM Employee e ORDER BY e.fchrEmployeeCode DESC");

报错:
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: ORDER BY 子句中的列 "HAS_Employee.fchrEmployeeCode" 无效,因为该列没有包含在聚合函数或 GROUP BY 子句中。

fchrEmployeeCode字段是字符串类型,但实际数据都是int类型,想根据它来排序。
数据库是sql server2005 之前的Mysql 好像不报错,查了好多资料还是不解。
...全文
评论 3
收藏 已收藏
分享
返回顶部
「已注销」
Java EE 67,535 成员 225,843 内容