【发布时间】:2017-02-02 21:30:35
【问题描述】:
我正在尝试从 SpringBoot 存储库运行以下查询
@Query("select * from c where id1 =?0 and id2 =?1 and id3 =?2 and c1 =?3 and year in :year and month in :month and day in :day and hour in :hour and minute in :minute"
public List<Counter> findCWithinRangeIn(
@Param("id1") String id1,
@Param("id2") String id2,
@Param("id3") String id3,
@Param("c1") String c1,
@Param("year") List<Integer> year,
@Param("month") List<Integer> month,
@Param("day") List<Integer> day,
@Param("hour") List<Integer> hour,
@Param("minute") List<Integer> minute);
但总是遇到错误:绑定变量的数量无效。
请就如何进行下一步提出建议。
注意:我确实关注了Spring CrudRepository findByInventoryIds(List<Long> inventoryIdList) - equivalent to IN clause,但它对我不起作用。
我想执行类似的操作:
select * from c
where id1 ="xyz" and
id2 ="abc" and
id3 ="pqr" and
c1 = "Sample" and
year IN (2016,2017) and
month IN (9,10,11) and
day IN (19,20,24) and
hour IN (23, 13) and
minute IN (50, 51, 53)
【问题讨论】:
-
在我的脑海中,你正在混合绑定方法让我很困扰。您正在使用 ?0、?1 等,但您正在命名参数(id1、id2)。如果将 ?0 更改为 :id1 并将 ?1 更改为 :id2 等会发生什么?
-
那也行不通
标签: spring-boot cassandra