特定HQL查询(休眠)的连接错误预期路径

时间:2020-01-15 12:13:38

标签: java spring java-8 hsqldb

对于HQL查询,出现以下错误。

我可以看到路径是正确的,我不明白这里缺少什么。

可以帮忙吗?

由于:org.hibernate.hql.internal.ast.QuerySyntaxException:路径 期待加入! [选择不同的来源 com.mandatum.epeli.model.domain.GroupCoverPeriod rt内联接 rt.pensionGroup el LEFT JOIN rt.insuranceCoverInfos ici LEFT JOIN rt.insuranceCoverInfoFuneralGrants第三次INNER JOIN BenefitChunks e ON e.insuranceCoverInfoId = tt或e.insuranceCoverInfoFGId =第tHERE个 el.id =?1 AND rt.startDate <=?2 AND(rt.endDate为NULL或 rt.endDate> =?2)AND UPPER(e.benefitsId)= UPPER(?3)] org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74) 在 org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:91) 在org.hibernate

@Query(value =
        "SELECT DISTINCT rt FROM GroupCoverPeriod rt " +
                "INNER JOIN rt.pensionGroup el " +
                "LEFT JOIN rt.insuranceCoverInfos ici "+
                "LEFT JOIN rt.insuranceCoverInfoFuneralGrants tth "+
                "INNER JOIN benefitChunks e ON e.insuranceCoverInfoId = tt " +
                "OR e.insuranceCoverInfoFGId = tth " +
                "WHERE el.id = ?1 " +
                "AND rt.startDate <= ?2 " +
                "AND (rt.endDate IS NULL OR rt.endDate >= ?2) " +
                "AND UPPER(el.benefitsId) = UPPER(?3)")
List<GroupCoverPeriod> findByActivePeriodAndInsuranceCoverInfo(long groupId,
                                                               LocalDate periodStartDate,
                                                               String benefitsId);

实体的详细信息如下

enter image description here

1 个答案:

答案 0 :(得分:1)

"INNER JOIN benefitChunks e ON e.insuranceCoverInfoId = tt " +
            "OR e.insuranceCoverInfoFGId = tth " + 

内部连接后,它期望现有/先前提到的实体的路径/字段之一。不是新提到的实体“ benefitChunks e”的字段/字段。

相关问题