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

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

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