没有输入参数的带连接的命名查询

时间:2017-08-16 17:23:29

标签: sql hibernate jpql named-query

过去几天我一直在尝试将此sql转换为命名查询并失败。这是sql

select * from EACI ci
LEFT OUTER JOIN EAT eat
ON ci.user_id = eat.user_id 
WHERE ci.commodity_code = eat.commodity_code and ci.auditor_type <> eat.auditor_type and eat.IS_LATEST ='Y' 

EACI和EAT不是直接加入,而是通过另一个表User

加入
    @NamedQuery(
    name = "ACI.findMismatch", 
    query = "select aci from AuditorCommodityInfo aci "
            + " inner join aci.user user "
            + " inner join fetch user.auditorTrackings tracking "
            + " WHERE tracking.isLatest= 'Y'"
            + " and aci.auditorType <> tracking.auditorType "
            + " and aci.commodity.code = tracking.commodity.code "
            )

我在这里做错了什么?

0 个答案:

没有答案