0

I have an entity Movements with 3 date: dateCompte, dateValeur and dateOperation. In my repository i have a query that search Movements according these three date. Now i would like to write a query that enable the user to search by using only dateCompte or dateValeur or dateOperation. In my front end i will have a drop down list to choice the kind of date that i would like to use for the search. How i can do it? Here is my repository:

@Query("select mvt from Mouvements mvt where mvt.compte.numCompte like :x and "
        + "(mvt.dateCompte between :y and :z "
        + "or mvt.dateValeur between :y and :z "
        + "or mvt.dateOperation between :y and :z)")
public Page<Mouvements> getMouvementsByCompteAndDate(@Param("x")long numCompte, 
                                                    @Param("y")LocalDate dateBefore, 
                                                    @Param("z")LocalDate dateAfter, Pageable pageable)
Syllaba Abou Ndiaye
  • 213
  • 1
  • 7
  • 21
  • 1
    Possible duplicate of [Dynamic spring data jpa repository query with arbitrary AND clauses](https://stackoverflow.com/questions/28874135/dynamic-spring-data-jpa-repository-query-with-arbitrary-and-clauses) – Jens Schauder Jan 17 '19 at 06:05
  • Try the spring specification it's better way you can do – avishka eranga Jan 18 '19 at 10:59

0 Answers0