java - JPA EJB Jackson Serialization Infinite Recursion Occurs Even With @JsonManagedReference Annotation -
i feel have done ton of research how jackson's serialization/deserialization occurs , found this blog post helpful. however, despite best efforts, continue receive recursive json. have 2 models - call them company , employee.
company , employee joined in database in normalized table mapping fk's company_id employee_id when employee moves company, still employee. companies have 1:n relationship employees
from employee model:
@manytoone @jointable(name="company_employee", joincolumns = { @joincolumn(name = "employee_id") }, inversejoincolumns = { @joincolumn(name = "company_id") }) @jsonmanagedreference private company company; public company getcompany() { return this.company; } public void setcompany(company company) {this.company = company;}
now, company model:
@onetomany(mappedby="company") @jsonbackreference private list<employee> employees; public list<employee> getemployees() { return employees; } public void setemployees(list<employees> employees) { this.employees = employees; }
do need @jsonignore
on getters or something? have clue missing here? want employees not show when retrieving company or companies. want company appear every employee, however.
Comments
Post a Comment