开发者

Pre loading objects in an HQL query

I'm using the following HQL query to try and load a set of objects when I select a Student object based on the advice found at the following link. http://www.javalobby.org/articles/hibernate-query-101/

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

I get the following error. unexpected token: left near line 1, column 64 I've pasted the relevant section of my mapping file below.

<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" />
&l开发者_JAVA技巧t;/set>


The HQL syntax is wrong. The JOIN clause belongs before the WHERE clause.

The HQL syntax is based on the SQL syntax. If you don't know SQL syntax very well, you may run into trouble with HQL syntax as well. I can recommend you the SQL tutorial at w3schools.com.

Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜