I have two entities:
Parent {
Child[] children;
}
and
Child {
Parent parent;
}
I'm aware about @JsonBackReference and @JsonManagedReference.
They are good, if I'm serializing instances of Parent.
But I also need to transfer instances of Child and I want to have the parent field populated.
In other words:
- On serialization of
Parentit should havechildrenbut their parent field might be empty (can be solved by using json reference annotations). - On serialization of
Childit should haveparentwith theirchildren(butchildrendon't have to haveparentpopulated.
Is there a way to solve it using standard Jackson capabilities?
I.e. skip serialization of entities which were already serialized instead of marking fields eligible or non-eligible for serialization.