JPA GROUP BY entity - is this possible?

前端 未结 3 1600
逝去的感伤
逝去的感伤 2021-02-07 03:16

Is possible to select data in JPA with grouping by referenced entity?

I mean: I have two entities - insurance and referenced many-to-one vehicle. Insurance entity has va

3条回答
  •  后悔当初
    2021-02-07 03:58

    Please explicitly use JOIN in this use case:

    SELECT ve, MAX(v.validTill)
    FROM TraInsurance v JOIN v.vehicle ve
    GROUP BY ve
    ORDER BY MAX(v.validTill)
    

提交回复
热议问题