JPQL Like Case Insensitive

前端 未结 4 1771
醉梦人生
醉梦人生 2020-12-06 09:00

I want to search data in User table by name case insensitive.

@Repository
public interface UserRepository extends JpaRepository {

  @Query         


        
4条回答
  •  误落风尘
    2020-12-06 09:42

    If that is only what you want and you are using Spring Data JPA you don't need to write a query.

    List findByNameContainingIgnoreCase(String name);
    

    Else you need to wrap the name attribute with % before you pass it to the method (putting those directly in the query will simply not work). Or don't use a query but use a specification or the Criteria API to create the query.

提交回复
热议问题