In spring java especially in JoinColumn, if we do JoinColumn for example JoinColumn(name="guest_id"). Then all guest data will be displayed. Whereas I only want to retrieve only one data, which is the name only.
@Column(name = "guest_id")
private Integer guestId;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "guest_id", insertable = false, updatable = false)
private String guestName;
When a request is made at postman, the result will be like this
"guestCard": {
"id": 53,
"idPic": null,
"guestType": null,
"title": "mr",
"name": "RIKO JANUAR",
"phoneNumber": "08100000",
"email": "riko@email.com",
"gender": "male",
"bDay": "2019-10-29",
"nationality": "AF",
"idCard": "21321131231",
"validity": "2019-10-29",
"telpFax": null,
"address": "bandung",
"job": "Musician"
}
What I want is to take and display only one, which is the name. Like this
"guestCard": {
"name": "RIKO JANUAR"
}
I tried it this way but it didn't work
@Column(name = "guest_id")
private Integer guestId;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "name.guest_id", insertable = false, updatable = false) //this is not work
private String guestName;