使用子查询在Hibernate中进行LEFT JOIN FETCH

时间:2019-04-17 22:36:41

标签: hibernate jpa spring-data-jpa hql

我得到错误 org.hibernate.hql.internal.ast.QuerySyntaxException: 它是我对HQL的查询

 @Query(value = "FROM RateValue r "
            + "LEFT JOIN FETCH r.status "
            + "LEFT JOIN FETCH r.rate "
            + "LEFT JOIN FETCH r.parameterValues v "
            + "LEFT JOIN FETCH v.status "
            + "LEFT JOIN (select * from parameter p "
            + "WHERE p.status_id = 1) p on p.id = v.parameter.id "
            + "WHERE r.status_id= 1 AND r.rate.id=:rateId AND r.branchValue in :branchCodes"

我尝试更改在mysql中有效的查询

select *
FROM rates.rate_value r
  left join rates.status s on s.id = r.status_id
  left join rates.rate ra on ra.id = r.rate_id
  LEFT JOIN rates.rate_parameter_value rrp on r.id = rrp.rate_value_id
  LEFT join rates.parameter_value pV on rrp.parameter_value_id = pV.id
  LEFT JOIN (SELECT * from
                rates.parameter p
              WHERE (p.status_id = 1 ) ) p on p.id=pV.parameter_id

有人知道如何用此SQL正确编写HQL查询吗?

0 个答案:

没有答案