tags:

views:

133

answers:

1

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" />
</set>
+3  A: 

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.

BalusC
Thanks, moving the join fixed the problem. APparently the syntax in the link I refferenced was wrong, my SQL is a bit rusty so I'll check out the tutorial link you posted.
Jared