0
Ladies and gentlemen, I have the following question. I have an application in Rest that when I ask to return the list, comes with many unnecessary fields, "example below". How do I select the attributes of the Entity class that it should return?
My get:
@GetMapping
public List<Nota> listNotas(){
return notaRepository.findAll();
}
When I get a get I get the following return.
{
"id": 28,
"nota": 10,
"dataNota": [
2017,
10,
10
],
"professor": {
"id": 1,
"nome": null,
"matricula": null,
"observacao": null,
"dataNascimento": null,
"ativo": null
},
"materia": {
"id": 1,
"nome": null
},
"aluno": {
"id": 1,
"nome": null,
"matricula": null,
"observacao": null,
"dataNascimento": null,
"ativo": null,
"nomeResponsavel": null,
"foneResponsavel": null
}
}
I would like you to return with fewer fields as per ex.
{
"id": 28,
"nota": 10,
"dataNota": [
2017,
10,
10
],
"professor": {
"id": 1,
"nome": null,
},
"materia": {
"id": 1,
"nome": null
},
"aluno": {
"id": 1,
"nome": null,
"matricula": null,
}
}
In this case, I think the best way would be to create a specific query to return the results you want...
– Uriel Hass