spring-boot - findAllByTimeStampBetweenAndStoreIn(Long startTime, Long endTime, List商店)不工作
问题描述
我正在尝试从给定的 timeStamp 和给定的商店列表中获取数据Elastic Index
,但是当我通过遍历 listOfStores 来完成它时,它工作正常,我正在获取该特定的数据store
listOfStores.forEach( i -> {
List<InStoreDemographicIndex> inStoreDemographicIndices =
inStoreSearchRepo.findAllByTimeStampBetweenAndStore(startTime, endTime, i));
})
但在我努力的同时,
List<InStoreDemographicIndex> inStoreDemographicIndices = inStoreSearchRepo
.findAllByTimeStampBetweenAndStoreIn(startTime, endTime, listOfStores);
一次只传递一个商店,这个查询不起作用,结果我得到了所有商店的数据,即使我只传递一个商店。
解决方案
嗯,找了好久才得到这个问题的答案,终于在spring data ElasticSearch下得到了我的答案8.2.2 Query creation
。
Store
由于存储库方法中使用的变量,上述查询不起作用,
In Service Class:
列出 inStoreDemographicIndices = inStoreSearchRepo .findAllByTimeStampBetweenAndStoreIn(startTime, endTime, listOfStores);
OLD inStoreSearchRepo Repository:
List<InStoreDemographicIndex> findAllByTimeStampBetweenAndStoreIn(Long startTime, Long endTime, List<String> Store);
而不是 Store in 应该是商店。
Correct inStoreSearchRepo Repository:
findAllByTimeStampBetweenAndStoreIn(Long startTime, Long endTime, List stores
);
所以总而言之:
假设如果字段名称是store
,
您的存储库方法应该是List<Object> findAllByStoreIn(List<String> stores);
谢谢..!!
推荐阅读
- c# - 如何使用硒下载图像?
- c# - 如何在 c# 中使用 openxml 生成的 word 文档中减小文本的字体大小或间距
- c++ - llvm 深度优先搜索从返回块
- c++ - 为什么 GSL-Lite 试图包含
? - java - spring boot 应用程序如何在幕后连接 mongodb 及其 Document
- angularjs - 如何为 Typescript/angularjs 项目生成虚假的覆盖率报告,覆盖率为 0%?
- java - Maven 测试传递范围
- r - 我应该如何将自定义函数导入 RMardown 文件?
- jquery - 根据 id 显示行
- datatable - 如何从网络而不是这个数据表呈现表格?