天天看点

hibernate查询报错

expecting IDENT错误解决办法

  (2010-11-09 16:16:41)

hibernate查询报错

转载▼

标签: 

it

分类: ThinkInJava

今天的开发爆出如下错误。

org.hibernate.hql.ast.QuerySyntaxException: expecting IDENT, found '*' near line 1, column 10 [select a.* from com.jyzq.hr.bean.Archive a,com.jyzq.hr.bean.Employee e,com.jyzq.hr.bean.Department d where a.contractEndDate = :date and a.status = 'A' and a.empId = e.id and e.status = 'A' and e.type = 'A' and e.deptid=d.id and d.type='A']

 at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:31)

 at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:24)

 at org.hi

原因是hql语句报错。

hql:select a.* from Archive a,Employee e,Department d where a.contractEndDate = :date and a.status = 'A' and a.empId = e.id and e.status = 'A' and e.type = 'A'

把hql改为如下形式,则编译通过。一切正常

select a from Archive a,Employee e,Department d where a.contractEndDate = :date and a.status = 'A' and a.empId = e.id and e.status = 'A' and e.type = 'A'

select 后面为对象 a .而非 a.*