我正在使用Spring框架,在以下的存储库currentOrder方法中,我将日期作为参数发送,但是当我执行此操作时Parameter with that position [1] did not exist
异常抛出
我发送以下网址
http://localhost:3000/api/orders/search/currentOrder?fromDate=2017-04-28&toDate=2017-05-02
我的代码中的错误在哪里?
public interface OrderRepository extends JpaRepository<Order, Long> {
@PreAuthorize("hasAuthority('rights')")
@Query("Select o.orderDate from Order o where o.orderDate between fromDate and toDate")
List<Order> currentOrder(@Param("fromDate") Date fromDate,@Param("toDate") Date toDate);
}
答案 0 :(得分:1)
您的参数未在查询中使用。请尝试通过 @Query("Select o.orderDate from Order o where o.orderDate between :fromDate and :toDate")
List<Order> currentOrder(@Param("fromDate") Date fromDate,@Param("toDate") Date toDate);
?#{fromDate}
还可以参考@Override
public void onResponse(String response) {
// Log.e(TAG,response); or Log.v(TAG,response)
if (response.trim().equals("success")) {
openProfile();
} else {
Toast.makeText(LoginActivity.this, response, Toast.LENGTH_LONG).show();
}
}
请参阅pass additional attributes