%Like% Query in spring JpaRepository %Like% Query in spring JpaRepository java java

%Like% Query in spring JpaRepository


The spring data JPA query needs the "%" chars as well as a space char following like in your query, as in

@Query("Select c from Registration c where c.place like %:place%").

Cf. http://docs.spring.io/spring-data/jpa/docs/current/reference/html.

You may want to get rid of the @Queryannotation alltogether, as it seems to resemble the standard query (automatically implemented by the spring data proxies); i.e. using the single line

List<Registration> findByPlaceContaining(String place);

is sufficient.


You dont actually need the @Query annotation at all.

You can just use the following

    @Repository("registerUserRepository")    public interface RegisterUserRepository extends JpaRepository<Registration,Long>{        List<Registration> findByPlaceIgnoreCaseContaining(String place);    }


You can also implement the like queries using Spring Data JPA supported keyword "Containing".

List<Registration> findByPlaceContaining(String place);