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.
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()));
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--
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()));