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

83
Views
org.springframework.data.domain.Sort why the error

I use org.springframework.data.domain.Sort:

Sort sortDesc = new Sort(Sort.Direction.DESC, "id");

as in the examples. But I get an error: Error:(47, 55) java: incompatible types: java.lang.String cannot be converted to java.util.List<java.lang.String>

I tried this:

List<Sort.Order> orderList = new ArrayList<>();
orderList.add(new Sort.Order (Sort.Direction.ASC, "id"));
Sort sort = new Sort(orderList);

But I get an error:

Error:(55, 21) java: Sort(java.util.List<org.springframework.data.domain.Sort.Order>) has protected access in org.springframework.data.domain.Sort

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I suspect you are trying to Sort data from your Spring Data JPA. You cannot call Sort and instantiate it, to my knowledge. You might have been looking for something like:

List<Item> item = repository.findAll(Sort.by(Sort.Direction.DESC, "id");

As you can see in the documentation, Sort has a protected constructor and cannot be called directly in the way you are trying to instantiate it. [https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/domain/Sort.html][Spring Documentation on Sort]

I am missing too much information about the rest of your project and how you setup your data with Spring Framework to give any other information.

over 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!