Spring data jpa findBy ...... with multiple columns but save search text

I am using spring jpa data and have a query to search for text from all columns.

eg:

repository.findByNameContainingOrAliasContaining (name, alias, page)

Both the name and the nickname are the same meaning, and I have to write like

string name = text; string alias = text,
repository.findByNameContainingOrAliasContaining (name, alias, paged)

and in fact, I have 5 columns to match, so how can I stop writing the same dumb code? and make the code like: repository.findByNameContainingOrAliasContaining(text, pageable)(now this letter will raise a ".NoSuchElementException")

repository

+4
1

, @Query:

@Query("select f from Foo f where f.name like %?1% or f.alias like %?1% or ...")
public List<Foo> findByAnyColumnContaining(String text, Pageable pageable);
+3

Source: https://habr.com/ru/post/1531127/


All Articles