I have a use case of using joins to update the values in one table along with having a check to check the alertType which is in another table for which I have to use the join b/w two tables.
Query –
@Modifying
@Transactional
@Query("""
UPDATE ItemAlert ia
SET ia.alertCount = ia.alertCount + 1
WHERE ia.alertId = :alertId
AND ia.podId = :podId
AND ia.alertHeader.alertType = :alertType
""")
void updateAlertCount(@Param("alertId") Integer alertId,
@Param("alertType") AlertType alertType,
@Param("podId") Integer podId);
Error –
org.hibernate.query.SemanticException: Entity join did not specify a predicate, please define an on clause or use an explicit cross join:
Also If I go with traditional method of using from table t inner
join table t This approach doesn’t work in JPQL. But while using the
join in Select query this works why?
Tried all possible ways not getting any resolution to this.
Note:- attribute alertId is there in both tables but there is no direct mapping between tables.