0
votes

I would like to write a like query in JpaRepository but it is not obeying the like query :

LIKE "abc" and "abc.com" are two string and when we do like :

@Query("Select * from table_name where column_name  like ?0'%' ALLOW FILTERING ")
List<entity> findPlaceContainingKeywordAnywhere(String keyword)

it is returning both the values when we pass :

repository.findPlaceContainingKeywordAnywhere("abc.")
1

1 Answers

1
votes

Your code will search only string starting with "abc." also I think there is some issue with query

Try this

@Query("Select * from table_name where column_name  like %:keyword% ALLOW FILTERING ")
List<entity> findPlaceContainingKeywordAnywhere(@Param("keyword") String keyword)