Hibernate order by 查询问题
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 好像不报错,查了好多资料还是不解。