I use jhipster to generate 2 entity Employee and Department
and relationship:
- Employee.java
@ManyToOne
@JsonIgnoreProperties(value = "employees", allowSetters = true)
private Department department;
- Department.java
@OneToMany(mappedBy = "department")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private Set<Employee> employees = new HashSet<>();
and when I called api/employees , I had:
{
"id": 1,
"code": "FU_EMP_DTP726",
"name": "Concrete system",
"birthDate": "2020-11-30",
"address": "Granite frame",
"phone": "0152104977",
"salary": 65309.0,
"department": {
"id": 1,
"code": "FU_DE_787778",
"name": "Tools"
}
}
but with api/departments , I had:
{
"id": 1,
"code": "FU_DE_787778",
"name": "Tools",
"employees": null
}
I didn't know why department's employees is null