0

I would like to do a string search on all the columns in my table or view in my database.

Below is my SQL query.

SELECT * 
FROM MY_FAVORITE_MOVIES as t 
where t::text like '%srk%'

The above query would do a search of the string in all the columns of the table. How to do the same with JPA criteriaBuilder API?

I tried using the like operation but it seems like I have to do a string search for each and every column. Is there a way to do a search string in all columns at once.

srk
  • 4,857
  • 12
  • 65
  • 109

1 Answers1

1

No, this is not possible with JPA. You must query all fields separately. Or you may just trigger your SQL query as a native query from JPA.

OndroMih
  • 7,280
  • 1
  • 26
  • 44