I am very new to DTO,
In my project, I have a database with a Team table (team_id, team_name) and User table (..., team_id) . Relation : a Team can have many users. a user belongs only to one team.
In my classes I added a Team team attribut in the User entity and I did some joining Jpa annotation to both the entities.
@ManyToOne
@JoinColumn(name = "id_team")
private Team team;
When i launch a findall request from my user entity I get in response a json with a team Object.
{
...
"id_team": 1,
"team": {
"id": 1,
"name": "team1"
}
}
My idea is to get only a the team name in the response object like this :
{
...
"id_team": 1,
"team_name": "team1"
}
I tried adding a string attribut to my user class but it tels me that no Column is referenced by this attribut which is reasonable.
Waiting for your suggestions Thank you