1

我有两张表,一张用于派对,一张用于记分卡模板映射。记分卡模板映射表有一个外键返回该方(在 id 上)。我想查找具有记分卡模板映射详细信息的所有各方的列表。

但我收到一条错误消息:

java.lang.IllegalArgumentException:org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:在第 1 行附近,第 172 列 [从 com.kpisoft.common 中选择新的 ScorecardTemplateMapping(p,temMap.scoTemplate,temMap.wrkFlwTemplate)。 web.domain.Party p left outer join ScorecardTemplateMapping temMap on temMap.organization.id=p.id and temMap.gradeType.id=:gradeType where p.organization.organizationTypeId=:orgType and p.clientId=:clientId order by p.机构名称]

这是我的查询:

查询q = entityManager.createQuery("select new ScorecardTemplateMapping(p,temMap.scoTemplate,temMap.wrkFlwTemplate) from Party p left outer join ScorecardTemplateMapping temMap on temMap.organization.id=p.id and temMap.gradeType.id=:gradeType where p.organization.organizationTypeId=:orgType and p.clientId=:clientId order by p.organization.name");

我不知道为什么这不起作用。请帮忙!

4

1 回答 1

1

关于语法错误的错误消息非常清楚:

unexpected token: on

JPQL 中不支持使用 ON [conditional] 进行连接(ON 不是保留字)。例如,在 JPQL 中如何进行连接。归结为您必须在 where 子句中提出连接条件。

于 2012-04-18T05:04:33.533 回答