0

I generated the where query. It's always different. Is there a way to use this WHERE in the @Query for a JPARepository

@Query("SELECT e FROM Entity e WHERE :whereQuery") 
List<Entity> getEntity(@Param("whereQuery") String whereQuery);
J. H
  • 102
  • 11
  • No. JPQL would interpret that as a boolean, not a String, and is then compiled. Dynamic queries are done using criteria. –  Nov 21 '18 at 17:56
  • @BillyFrost criteria I would better do with the EntityManager right? – J. H Nov 21 '18 at 17:57
  • Take a look at this: https://stackoverflow.com/questions/28874135/dynamic-spring-data-jpa-repository-query-with-arbitrary-and-clauses – Robert Niestroj Nov 21 '18 at 18:25
  • Specifications is the way to go: https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#specifications QueryDSL is no longer maintained. – Simon Martinelli Nov 21 '18 at 19:49

0 Answers0