Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

909
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda