1

Supposing I have a Product table in my database with the following columns: id, name, and description. I want to write a query in ProductRepository which extends JPA Repository, that allows me to retrieve a list of products whose description or name contain some given words. These words come from a string array.

I managed to implement this query for only a single word given and it works, but can't figure out how to do it for multiple words.

I appreciate any advice you could give me!

ProductRepository:

@Query(value="SELECT * FROM product WHERE description LIKE CONCAT('%',:word,'%') OR name LIKE CONCAT('%',:word,'%')", nativeQuery =true)

Set findProductsByGivenWords(String [] words); enter image description here

0 Answers0