2012-04-18 118 views
1

我有兩個表格,一個用於派對,一個用於記分卡模板映射。記分卡模板映射表具有返回到該方的外鍵(在ID上)。我想查找具有記分卡模板映射詳細信息的所有參與方的列表。執行JPA中的左連接查詢

,但我得到它說的錯誤:

java.lang.IllegalArgumentException異常: org.hibernate.hql.internal.ast.QuerySyntaxException:意外的標記: 近線1,列172選擇新 ScorecardTemplateMapping(p,temMap.scoTemplate,temMap.wrkFlwTemplate) 從com.kpisoft.common.web.domain.Party p左外側上temMap.organization.id = p.id和 temMap.gradeType加入 ScorecardTemplateMapping temMap。 id =:gradeType其中 p.organization.organizationTypeId =:orgType和p.clientId =:客戶端ID 爲了通過p.organization.name]

這是我的查詢:

查詢Q = entityManager.createQuery(「選擇新 ScorecardTemplateMapping(P,temMap.scoTemplate,temMap.wrkFlwTemplate) 甲方p左外連接ScorecardTemplateMapping temMap上 temMap.organization.id = p.id和temMap.gradeType.id =:gradeType其中 p.organization.organizationTypeId =:orgType和p.clientId =:用p的clientId 順序。機構名稱」);

我不知道爲什麼這不起作用。請幫忙!關於語法錯誤

回答

1

錯誤信息是很清楚的:

unexpected token: on 

沒有支持,使與ON [有條件]在JPQL(上未保留字)加入。在JPQL中如何進行連接,例如here。這歸結爲你必須在where子句中呈現連接條件。