我正在
QuerySyntaxException: expecting "all", found 'JOIN' near line 1, column 50 [SELECT p FROM com.rr.model.Person p FETCH JOIN p.positions pos WHERE p.id=:id]
Hibernate的异常。将“JOIN”更改为“ALL”无效并产生以下错误:
QuerySyntaxException: expecting "properties", found 'p' near line 1, column 54 [SELECT p FROM com.rr.model.Person p FETCH ALL p.positions pos WHERE p.id=:id]
发生了什么以及正确的查询应该如何?
答案 0 :(得分:5)
问题是我将语法切换为'FETCH JOIN'形成正确的语法:'JOIN FETCH'。正确的查询应该如下所示
SELECT p FROM Person p JOIN FETCH p.positions pos WHERE p.id=:id
'ALL'的正确语法如下所示:
SELECT p FROM Person p FETCH ALL PROPERTIES WHERE p.id=:id