0

I have a repository:

public interface ItemRepository extends PagingAndSortingRepository<Item, Long> {

    List<Item> findByNameContainingIgnoreCase(@Param("name") String name);

}

I would like the find method to accept a list of words and find items which contain all words in their name. Something like:

List<Item> findByNameContainingAllIgnoreCase(@Param("name") String[] name);

Is this possible?

aycanadal
  • 1,106
  • 2
  • 15
  • 42
  • You will need to write a native query - which is probably not straightforward and probably DBMS dependant. Once you have worked out how to do that you can use the annotation @Query(value="my complex sql", native=true) on your query method. See for example: http://stackoverflow.com/questions/14290857/sql-select-where-field-contains-words – Alan Hay Nov 03 '16 at 13:18
  • Another option would be to create a Custom Repo that used some specific functionality of your JPA provider. If, for example, you were using Hibernate you could utilise Hibernate search. http://hibernate.org/search/documentation/getting-started/ – Alan Hay Nov 03 '16 at 13:23

0 Answers0