0

I'm doing a React + Springboot application. In some part of the app I have a four selectors and a button to search("Buscar"). Like this

What I'm trying to do is a conditional query depending on which values are selected. With this code below I can do the query if all the values are filled but if some is missing it throws an error ( Current Query )

I think it may be with the Specifiaction or something like that not sure yet

anmursas
  • 3
  • 2

1 Answers1

0

You can create custom queries in spring data jpa using specifications

Here you conditionally add create criteria queries.
ref:

https://reflectoring.io/spring-data-specifications/

https://spring.io/blog/2011/04/26/advanced-spring-data-jpa-specifications-and-querydsl/

This can help you with all your custom permutations and combinations.

swapyonubuntu
  • 1,952
  • 3
  • 25
  • 34
  • y, im trying that but i run into the same problem, do I have to create 24 IF condition to evaluate every combination? Or theres some way that Specification can resolve it? – anmursas Oct 05 '22 at 10:03