I need to pass in a variable number of parameters to a spring/JPA repo to mimick something like this.
select * from myTable
where name like '%SOME_VALUE%'
or name like '%SOME_OTHER_VALUE%'
or name like '%SOME_OTHER_VALUE2%'
or an unknown number of other values
So far I haven't been able to determine what the correct way to to do this is. I'm using Spring 4.3.7, Hibernate 5.2.9, and Spring Data 1.11.1. I've googled around and it doesn't appear that there's way to do this with a normal CRUD repo, but so far I haven't found any examples that look like what I need. I think CriteriaBuilder is what I am supposed to use, but that seems to have fallen out of favor, so I'm not sure what the correct way to do this is.
List<YourTableEntity> find(String param1, String param2....)method with an annotation like@Query("SELECT y FROM YourTableEntity y WHERE y.name like '%:param1%' or like y.name like '%:param2%' ....be sufficient?SELECT * FROM Table t WHERE t.col1 LIKE %?1% OR t.col2 LIKE %?2% OR t.col3 LIKE %?3%