简体   繁体   中英

Path expected for join Error for a specific HQL Query (Hibernate)

I get the following error for a HQL query.

I can see the path is correct, I fail to understand what is missing here.

Can you please help ?

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Path expected for join! [SELECT DISTINCT rt FROM com.mandatum.epeli.model.domain.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(e.benefitsId) = UPPER(?3)] at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74) at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:91) at 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);

Details of the entities are as follows

在此处输入图片说明

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

after inner join it expects one of path/field of existing/previous mentioned entity.field not a newly mentioned entity "benefitChunks e"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM