我想从单个提取查询中提取多个记录,为此我需要使用IN子句。但是当我运行它时,它不会返回任何记录。
public Map<String, List<EventDataRecords>> fetchEventdata_bkp(String interval, DateResolverResponse datePattern, List<AssetModelNode> entityIdList) throws ApplicationException {
logger.info("Entered fetchEventdata***");
Map<String,List<EventDataRecords>> eventDataResponseList = new HashMap<>();
int startDt=0;
int stopDt=0;
int year=0;
CountDownLatch latch;
latch = new CountDownLatch(entityIdList.size());
List<DateRange> dateRange = new ArrayList<>();
dateRange = datePattern.getDateRange();
long startTime = System.currentTimeMillis();
logger.info("fetchEventdata Approach2 startTime**"+ startTime+"/Interval--"+interval);
for(AssetModelNode entityId: entityIdList) {
List<EventDataRecords> rowList = new LinkedList<>();
EventDataRecords eventDataRecords = new EventDataRecords();
String assetId = entityId.getEntityId();
try {
if(interval.equals(BusinessConstants.DAY) && dateRange!=null) {
for(DateRange currRange: dateRange) {
startDt= currRange.getStartDay();
stopDt= currRange.getStopDay();
year=currRange.getCurrentYear();
int dayDiffer = ((stopDt- startDt)> 0 ? (stopDt- startDt):0);
latch = new CountDownLatch(dayDiffer+1);
while(startDt<=stopDt) {
eventDataRecords = new EventDataRecords();
Flux<AssetDailyTable> metricsDailyDataFlux = dataRepository.fetchDailyTableRecordsFlux(assetId,year,startDt);
metricsDailyDataFlux.subscribe(new MetricsDailyDataFluxSubscriber(eventDataRecords, latch));
rowList.add(eventDataRecords);
startDt ++;
}
}
eventDataResponseList.put(assetId, rowList);
}
}catch (Exception e) {
logger.error(e.getMessage());
}
}
try {
latch.await();//30, TimeUnit.MICROSECONDS);
} catch (InterruptedException e) {
logger.error("ERROR-0006: Unable to collate data, interrupted", e);
Thread.currentThread().interrupt();
}
return eventDataResponseList;
}
@Repository
public interface IDataRepository extends ReactiveCassandraRepository<AssetDailyTable, AssetDailyTablePK>{
@Query("SELECT * from dev_renwinddev_fx.event_metrics_asset_daily_data where assetid =?0 and year =?1 and day =?2")
public Flux<AssetDailyTable> fetchDailyTableRecordsFlux(String assetid, int startYr, int startDay);
}
在当前设计中,我必须为每个日期循环播放。 与其相反,我想通过-
List<Integers> days =[12,13,14,15];
fetchDailyTableRecordsFlux(assetId,year,days);
@Query("SELECT * from dev_renwinddev_fx.event_metrics_asset_daily_data where assetid =?0 and year =?1 and day IN ?2")