Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

908
Views
Spring Data JPA: case insensitive orderBy

I want to sort my entities by the name attribute with ascending direction and ignoring the case.

I've created an EntityRepository extending the Repository interface of Spring Data. Then I've declared the following find method:

List<Entity> findByNameOrderByNameIgnoreCaseAsc(String name);

But I get this error "No property ignoreCase found for type".

I can't find any reference to this case in the Spring Data JPA documentation.

I'm using spring-data-jpa version 1.11.0.

about 4 years ago · Santiago Trujillo
3 answers
Answer question

0

If you want just to return all entities with sorting by name with ignore case you can use this:

repository.findAll(Sort.by(Sort.Order.asc("name").ignoreCase()));
about 4 years ago · Santiago Trujillo Report

0

Spring Data IgnoreCase can be only used for finding by a property, and cannot be user in combination with Order by.

However you can get you results using Sort.Order.ignoreCase() and Pages http://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/domain/Sort.Order.html#ignoreCase--

about 4 years ago · Santiago Trujillo Report

0

Try instead creating the repository method below (notice the added sort parameter)

List<Entity> findByName(String name, Sort sort);

Then extend the PagingAndSortingRepository in this repository (with Long being whatever your entity id type is):

extends PagingAndSortingRepository<Entity, Long>

Then call the method as so:

repository.findByName("nameToFind", Sort.by(Sort.Order.asc("name").ignoreCase()));
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!