我有一个查询,我在哪里传递日期范围输入
@Query(value = "SELECT ord.purchaseOrderNumber,ord.salesOrderNumber,ord.quoteNumber"
+ " FROM Order ord WHERE ord.purchaseOrderNumber :poNumber and ord.receiveDate between to_date(:dateFrom,'MM/DD/YYYY') AND to_date(:dateTo,'MM/DD/YYYY')
所以我将有效数字传递给:poNumber并将空值传递给日期占位符,并且查询没有返回任何值,它应该基于:poNumber返回1行,那么我该如何处理这个NULL输入值到日期
答案 0 :(得分:0)
我想你需要ord.purchaseOrderNumber和ord.receiveDate之间的OR运算符
@Query(value = "SELECT ord.purchaseOrderNumber,ord.salesOrderNumber,ord.quoteNumber"
+ " FROM Order ord WHERE ord.purchaseOrderNumber :poNumber OR (ord.receiveDate between to_date(:dateFrom,'MM/DD/YYYY') AND to_date(:dateTo,'MM/DD/YYYY'))