0

If I have a created a query with multiple filters, than how I pass in my repository method.

@Query(value=":customQuery",nativeQuery=true)
public List<Employee> findAllBYFilters(String customQuery,@Param("isActive") boolean isVisible, @Param("pageRequest") Pageable pageRequest);

Please guide me how I pass a complex query(which I create in service class by using multiple filters) in this method.

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
Vikram Shekhawat
  • 627
  • 2
  • 8
  • 12
  • Please add the query to your question – devReddit Jul 21 '21 at 16:10
  • 1
    Your syntax looks off to me. The query itself should appear inside the `@Query` annotation, and the `:placeholders` should appear inside that raw query string. – Tim Biegeleisen Jul 21 '21 at 16:10
  • @devReddit my query is created at run time on the basic of multiple conditions. I have write one method to create query at run time – Vikram Shekhawat Jul 21 '21 at 16:12
  • 1
    I see what you try to do. I also think you'd probably want to use an EntityManager directly instead. Anyway, if you want to use the parameter `customQuery` in the value of `@Query`, you also need to specify it in the argument. In other words, add `@Param("customQuery")` before `String customQuery` – Jetto Martínez Jul 21 '21 at 16:18
  • @jetto yes I used EntityManager to solve this chalange – Vikram Shekhawat Jul 23 '21 at 03:18

0 Answers0