I am trying to serialize POJO to JSON but stuck in circular reference problem. I know how to handle one to many and reverse relationships using the @JsonBackReference
and @JsonManagedReference
.
My problem is with bidirectional many-to-many relation(eg a student can have many courses and each course can have many students enrolled), parent references child and child references back to parent and here my serializer dies. As per my understanding I cannot use @JsonBackReference
here as value type of the property must be a bean: it can not be a Collection, Map, Array or enumeration.
Can some one please advise how I can handle this scenario?