%Like% Query in spring JpaRepository

前端 未结 10 1692
南方客
南方客 2020-12-04 11:36

I would like to write a like query in JpaRepository but it is not returning anything :

LIKE \'%place%\'-its not working.

LIKE

10条回答
  •  无人及你
    2020-12-04 11:46

    Found solution without @Query (actually I tried which one which is "accepted". However, it didn't work).

    Have to return Page instead of List:

    public interface EmployeeRepository 
                              extends PagingAndSortingRepository {
        Page findAllByNameIgnoreCaseStartsWith(String name, Pageable pageable);
    }
    

    IgnoreCase part was critical for achieving this!

提交回复
热议问题