Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

910
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda