2017-07-11 6 views
0

パラメータ。パラメータのいずれか1つを指定し、残りのパラメータを指定しない場合は、org.hibernate.QueryException: Not all named parameters have been setとなります。これには解決策がありますか?オプションのHQLクエリは、私は残りリポジトリに持って

+0

パラメータを「null」に設定していますか?またはあなたはそれを一切受け入れません –

+0

私は郵便配達員を使ってテストします。 '&customer =&supplier ... 'のような空のパラメータを渡すかどうかは関係ありません。あるいは、まったく渡さなければ同じエラーが出ます。 – aycanadal

答えて

0

エンティティ名とバインドパラメータにSpELを混在させました。バインディングを使用する場合 ':parameterName' not::#{#parameterName} '

@Query(
      "SELECT ord FROM Order as ord where " + 
        " (:customer is null or :customer='' or ord.customer = :customer) and " + 
        " (:upplier is null or supplier='' or ord.supplier = :supplier) and " + 
        " (:startDate is null or :startDate='' or ord.date >= :startDate) and " + 
        " (:endDate is null or :endDate='' or ord.date >= :endDate)" 
    ) 
    Page<Order> query(
      @Param("customer") Organization customer, 
      @Param("supplier") Organization supplier, 
      @DateTimeFormat(pattern = "dd-MM-yyyyy") @Param("startDate") Date startDate, 
      @DateTimeFormat(pattern = "dd-MM-yyyyy") @Param("endDate") Date endDate, 
      Pageable pageable 
    ); 
関連する問題