我创建了以下形式的本机查询-
@Query(value="SELECT * FROM ORDER_DETAILS WHERE ORDER_ID IS NULL AND tag = ?2 AND CREATED_DATE >= ?3 AND STATUS IN ?1",nativeQuery=true)
List<Order> findCases(String status, String tag, Date date);
在我的情况下,参数如下-
String status="('ACCEPTED')";
String tag="0";
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, -5);
Date date =c.getTime();
在执行查询时,我不清空输出。但是当我在oracle上执行相同的查询(写在下面)时,我得到了所需的结果。
SELECT * FROM ORDER_DETAILS WHERE ORDER_ID IS NULL AND TAG = '0' AND CREATED_DATE >='23-11-2018' AND ORDER_STATUS IN ('ACCEPTED');
谁能告诉我我做错了什么?
答案 0 :(得分:1)
如果您想在 in 子句中使用,则将单个String作为参数没有什么意义。
@Query(value="SELECT * FROM ORDER_DETAILS WHERE ORDER_ID IS NULL
AND tag = ?2 AND CREATED_DATE >= ?3
AND STATUS IN ?1", nativeQuery=true)
List<Order> findCases(List<String> statuses, String tag, Date date);
List<String> statuses = new ArrayList<>();
statuses.add("ACCEPTED");
String tag="0";
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, -5);
Date date = c.getTime();
List<Order> order = repo.findCases(statuses, tag, date);