我创建了一个新的ItemType(SalesData),并尝试通过程序执行一个简单的查询,但未返回任何结果。在调试时,我复制了查询和相关的查询参数,并在hac上执行,该查询返回了结果。为什么此查询无法通过程序运行?基本上,问题出在fromDate和toDate。
private static final String SALES_QUERY = "SELECT {"+ SalesDataModel.PK +"} FROM {"
+ SalesDataModel._TYPECODE + " AS F } "
+ "WHERE {F:" +SalesDataModel.PUBLISHED + "} = false "
+ "AND {F:" + SalesDataModel.TRANSACTIONDATE + "} >= ?fromDateTime "
+ "AND {F:" + SalesDataModel.TRANSACTIONDATE + "} < ?toDateTime ";
private static final String FROM_DATE_TIME = "fromDateTime";
private static final String TO_DATE_TIME = "toDateTime";
private void generateSalesFile(LocalDateTime yesterdayMidnight, LocalDateTime todayMidnight) {
FlexibleSearchQuery query = new FlexibleSearchQuery(SALES_QUERY);
query.addQueryParameter(FROM_DATE_TIME, java.sql.Timestamp.valueOf(yesterdayMidnight));
query.addQueryParameter(TO_DATE_TIME, java.sql.Timestamp.valueOf(todayMidnight));
final SearchResult<SalesDataModel> result = flexibleSearchService.search(query);
}
答案 0 :(得分:1)
尝试使用Date
代替Timestamp
。