Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA findBy field ignore case

Tags:

How do I make findByIn search using IgnoreCase of <Field>? I tried to use findByNameIgnoreCaseIn and findByNameInIgnoreCase with no result. DB is Postgresql.

@Repository
public interface UserRepository {
    List<User> findByNameIgnoreCaseIn(List<String> userNames);
}
like image 448
Daria Bulanova Avatar asked May 30 '16 11:05

Daria Bulanova


People also ask

How do you make a case-insensitive in spring boot?

IgnoreCase for Case Insensitive Queries Now, suppose we want to perform a case-insensitive search to find all passengers with a given firstName. Here, the IgnoreCase keyword ensures that the query matches are case insensitive.

What is difference between JpaRepository and CrudRepository?

CrudRepository provides CRUD functions. PagingAndSortingRepository provides methods to do pagination and sort records. JpaRepository provides JPA related methods such as flushing the persistence context and delete records in a batch.

Is hibernate case sensitive?

Case Sensitivity. Queries are case-insensitive, except for names of Java classes and properties.

What is Spring Data JPA?

Spring Data JPA aims to significantly improve the implementation of data access layers by reducing the effort to the amount that's actually needed. As a developer you write your repository interfaces, including custom finder methods, and Spring will provide the implementation automatically.


1 Answers

Try something like this:

List<User> findByNameInIgnoreCase(List<String> userNames);
like image 127
Sumeet Tiwari Avatar answered Oct 01 '22 14:10

Sumeet Tiwari