我不会这样查询:
@Query(
nativeQuery = true,
value = "select vp.id , vp.identity, vp.vehicle_id, dt.i " +
"from vehicle_plate vp" +
" inner join (select max(vp2.id) as id, vp2.vehicle_id as vId from vehicle_plate vp2 group by vp2.vehicle_id) as vpg" +
" ON vp.id = vpg.id and vp.vehicle_id = vpg.vId" +
" cross join (values :dates ) dt(i)" +
"where vp.vehicle_id in (:vehicleIds)"
)
Page<Object[]> findAllJoinByDate(
@Param("dates") List<java.util.Date> dates,
@Param("vehicleIds") List<Integer> vehicleIds,
Pageable pageable
);
我的问题是查询cross join (values :dates ) dt(i)
的一部分和jpa未知的日期参数。
应与
相同cross join (values ('2019-10-08') , ('2019-09-07') ) dt(i)
有解决方案吗?