findAllbyId bringing the same result to the whole query

Asked

Viewed 20 times

-1

I’m having a small problem, my query is returning the same result on all Rows.

Example:

inserir a descrição da imagem aqui

Code:

@NamedQuery(name = "UtilizadorPerfil.getByFilter", query = "SELECT u FROM UtilizadorPerfil u WHERE COD_UTILIZADOR = ?1 ")

public class UtilizadorPerfil implements Serializable {

    private static final long serialVersionUID = -232601683121391563L;
    
    @Id
    private Long COD_UTILIZADOR;    
    
    private Long COD_PERFIL;

getters setters...

@Repository
public interface UtilizadorPerfilRepository extends JpaRepository<UtilizadorPerfil, Long> {

    List<UtilizadorPerfil> getByFilter(Long cod);

}

Chamada

@Autowired
UtilizadorPerfilRepository utilPerfil;

List<UtilizadorPerfil> utilizadoresPerfis = utilPerfil.getByFilter(id);

Possible answers to possible questions:

  • Yes, in the bank there is no similar result.
  • There is no relation with another table, even if it is a composite table, I cannot map the other tables, I just need to look for these results.

1 answer

1

I managed to solve the problem!

It was only @Id that was in the wrong key.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.