2017-05-05 25 views
0

我使用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); 
} 

回答

1

您的参数未在查询中使用。尝试,而不是由:paramName

@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}here

+0

它工作的提及他们:“d 感谢:'))))) – SFAH

+0

欢迎您然后接受的答案是正确的) – StanislavL

+0

当定时器关闭,我肯定接受答案 – SFAH