Hibernate查询:无法解析属性

时间:2013-01-31 17:38:48

标签: hibernate coldfusion hql

尝试运行此Hibernate查询时出现以下错误:

could not resolve property: candidateID of: result [select SUM(A.Points) from answer A Left Join A.Results R where R.candidateID = '465b4eb2-c306-4092-8914-d272b5a70b11']
QueryString     select SUM(A.Points) from answer A Left Join A.Results R where R.candidateID = '465b4eb2-c306-4092-8914-d272b5a70b11' 

select SUM(A.Points)
 from answer A
 Left Join A.Results R 
 where R.candidateID = '1234'

但是,candidateID在结果中,所以我不理解这个错误。

3 个答案:

答案 0 :(得分:1)

实体Results没有名为candidateID的字段。在HQL查询中,应该使用持久属性的名称(类中的〜字段)而不是数据库列的名称。

答案 1 :(得分:1)

除了Java类和属性的名称之外,HQL查询不区分大小写。所以org.hibernate.eg.FOO不是org.hibernate.eg.Foo。尝试更改查询中的类和属性的大小写。同时验证candidateID的大小写。

select SUM(A.points) from Answer A Left Join A.results R where R.candidateID = '465b4eb2-c306-4092-8914-d272b5a70b11']

答案 2 :(得分:1)

我不知道hibernate,但如果这是正常的sql这行是不完整的:

Left Join A.Results R

您必须指定加入条件,例如

Left Join A.Results R on a.candidateID = R.candidateID
相关问题