I know the title is not really explaining the problem so I will try to give more details.
I have a String in the Controller, something like this (keep in mind that this String is not manually written since it's dynamic, there are 7 filters and I want to return the information based on the filters selected, so I can't just put the String in the @Query value, since some filters will remain untouched and you cannot SELECT * WHERE value = *)
String query = "SELECT * FROM table WHERE column1=value1 AND column2=value2"
Now, the Queries are made in the Repository, but I really have no idea how to make the value of that query to be this String, something like this :
@Query(value = query, nativeQuery = true)
public List<ExampleEntity> testFunction(String query);
My first idea was to do this :
@Query(value = "?", nativeQuery = true)
public List<ExampleEntity> testFunction(String query);
But it inputs the whole String inside ' '
'SELECT * FROM table WHERE column1=value1 AND column2=value2'
(now that I think about this, it does that because the compiler sees this as like I'm trying to set the value of something to be the String, makes sense but I wish there could be a way to simply set the input of the function to be the value of the Query :/ )
Sooo ... is there any other way to use that string as the query value?