Announcement Announcement Module
Collapse
No announcement yet.
Sort case sensitivey in Spring Data (JPA) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sort case sensitivey in Spring Data (JPA)

    Hi,
    I have been dealing with an (intermittently) failing integration test that has led me to post this question; I'm essentially sorting some results by name:
    findAll( new PageRequest( page, size, new Sort( name ) ) );
    and I'm seeing that the sort is case insensitive; Is there any way to change that to case sensitive?
    Thanks.
    Eugen.

  • #2
    Hi, yes:

    You can extend of PagingAndSortingRepository

    Code:
    public interface CustomerRepository extends CrudRepository<Customer, Long>, JpaSpecificationExecutor<Customer>, PagingAndSortingRepository<Customer, Long>
    and use findAll(Sort sort)

    Code:
    repository.findAll(new Sort("lastname"))
    Result:

    Beauford
    Matthews
    Matthews
    Matthews
    Matthews
    lassard

    Comment


    • #3
      This is what I'm already using, but the question is - is the sort case sensitive or insensitive. As far as I can tell, it's case insensitive, which is not ideal. Is there any way to make it case sensitive?
      Thanks.
      Eugen.

      Comment


      • #4
        With my code above, it's sensitive, see the result of my execution (they are lastnames):

        Beauford
        Matthews
        Matthews
        Matthews
        Matthews
        lassard

        if it was insensitive the result would have been:

        Beauford
        lassard
        Matthews
        Matthews
        Matthews
        Matthews

        Comment

        Working...
        X