How to swap @JsonBackReference and @JsonManagedReference based on which Entity is reference

前端 未结 1 1161
孤街浪徒
孤街浪徒 2021-01-27 02:21

I\'m trying to find a way to swap the @JsonBackRefence and the @JsonManagedReference based on what entity I reference from the associated repository.

Site.java

相关标签:
1条回答
  • 2021-01-27 02:28

    If I understand you correctly the @JsonIgnoreProperties annotation should help you:

    @JsonIgnoreProperties("site")
    @OneToMany(mappedBy="site")
    private List<Building> buildings;
    
    @JsonIgnoreProperties("buildings")
    @ManyToOne
    private Site site;
    
    0 讨论(0)
提交回复
热议问题