jackk jackk - 22 days ago 9
Java Question

JsonManagedReference vs JsonBackReference

I would like to now what is the difference between @JsonManagedReference and @JsonBackReference in Jackson?

Answer

@JsonManagedReference is the forward part of reference – the one that gets serialized normally. @JsonBackReference is the back part of reference – it will be omitted from serialization.

So they really depend on the direction of your relationship

public class User {
    public int id;
    public String name;

    @JsonBackReference
    public List<Item> userItems; } 

public class Item {
    public int id;
    public String itemName;

    @JsonManagedReference
    public User owner; 
 }