2009-11-02 53 views
1

我使用以下HQL查询尝试加载一组对象,并根据在以下链接中找到的建议选择一个Student对象。 http://www.javalobby.org/articles/hibernate-query-101/在HQL查询中预加载对象

from gradebook.model.Student student where student.studentId=1 left join fetch student.scores 

我碰到下面的错误。 意外令牌:左边第1行,第64列 我粘贴了下面我的映射文件的相关部分。

<set name="scores" inverse="true" lazy="true" table="score" fetch="select"> 
<key> 
<column name="student_id" not-null="true" /> 
</key> 
<one-to-many class="gradebook.model.Score" /> 
</set> 

回答

3

HQL语法错误。 JOIN子句在之前属于WHERE子句。

HQL语法基于SQL语法。如果您不太了解SQL语法,那么您也可能遇到HQL语法问题。我可以推荐你SQL tutorial at w3schools.com

祝你好运。

+0

谢谢,移动连接解决了问题。另外,我所引用的链接中的语法是错误的,我的SQL有点生疏,所以我将查看您发布的教程链接。 – Jared 2009-11-02 15:31:31