【发布时间】:2019-01-31 18:05:47
【问题描述】:
以下查询返回一个列表,但我只对列表的最后一个元素感兴趣。
@Query("SELECT r FROM Reservation r WHERE r.reservationSeance.id=:seanceId AND r.seanceDate=:seanceDate")
public Reservation findReservationBySeanceDateAndSeanceId(@Param("seanceId") int seanceId, @Param("seanceDate") java.time.LocalDate seanceDate);
我应该如何重写 SQL 查询以实现我的想法?
【问题讨论】:
-
当查询本身没有定义排序时,“last”的含义有点模糊。没有它,您无法保证排序是一致的。
-
如果我有列表记录,我想获得具有最大 id 值的记录
标签: java sql spring spring-data-jpa