I have a search function which can handle multiple search texts. Now I like to query my db for items which contain at least one of the search texts.
For one search text, I am using the following:
import org.springframework.data.jpa.repository.Query;
@Query("SELECT m FROM Material m WHERE m.productName LIKE %:searchText%")
For a collection of search texts, I tried:
@Query("SELECT m FROM Material m WHERE m.productName IN (:searchTexts)")
Problem I'm facing is, that now only the exact productName matches the query. But I'm looking for partial matches as well. Something like:
@Query("SELECT m FROM Material m WHERE m.productName IN (%:searchTexts%)")
Is there any way using JPQL or do I have to use QueryDSL?