У меня есть сопоставление для двух сущностей, ProfileGroup
и User
, где у пользователя есть отношение @OneToMany
к ProfileGroups;
Проблема в том, что при возврате моей заявки не отображается Внешний ключ fk_user таблицы ProfileGroup в JSON-заявке для всех ProfileGroups.
ProfileGroup
public class ProfileGroup {
...
@ManyToOne(fetch=FetchType.EAGER)
@JoinColumn(name="fk_user_creator")
@JsonBackReference
private User userCreator;
...
Пользователь
public class User {
@OneToMany(mappedBy="userCreator")
@JsonManagedReference
private List<ProfileGroup> profileGroups;
Класс ресурса:
@GetMapping
public ResponseEntity<?> listAll(){
List<ProfileGroup> profileGroupsReturned = profileGroupRepository.findAll();
return !profileGroupsReturned.isEmpty() ? ResponseEntity.ok(profileGroupsReturned) : ResponseEntity.noContent().build();
И результат JSON: (НЕ ВИДИТЕ FK_USER)
[
{
"id": 1,
"name": "Calango Careta",
"description": "Cadê? cadê? Nós somos a Orquestra Camaleônica do Calango Careta!!!!!!!!",
"founded": "2015-04-12",
"registered": "2018-11-14",
"active": true
},
{
"id": 2,
"name": "Tropicaos",
"description": "",
"founded": "2018-01-20",
"registered": "2018-11-14",
"active": true
},
{
"id": 3,
"name": "Capivara Brass Band",
"description": "",
"founded": "2016-08-24",
"registered": "2018-11-14",
"active": false
}
]
Есть идеи? Что не так?
спасибо !!