Jpa查询将查询的一部分作为参数发送

时间:2019-07-11 08:13:36

标签: postgresql spring-boot jpa spring-data-jpa hql

我不会这样查询:

@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)

有解决方案吗?

0 个答案:

没有答案