jpa实体@ManyToOne @OneToMany无限递归
问题描述
Cannot call sendError() after the response has been committed
解决办法
在属性上添加注释
1 2 3 4 |
@JsonBackReference // data to json 和 JsonIgnore一样 // @JsonManagedReference // data to json 会被序列化 // @JsonIgnore // 直接忽略子实体 private Collection<ArticleEntity> articlesById; |
@JsonIgnore
序列化和反序列化过程中 都会忽略这个属性
@JsonManagedReference正常序列化 反序列化
@JsonBackReference序列化data to json过程中 ,会忽略这个属性
@OneToMany和@ManyToOne要素
cascade一的一方一般用: cascade = CascadeType.ALL
多的一方不用设置,默认不级联
fetch默认是lazy还是eager啊
mappedby 或者 joinColumn一的一方用mappedby
多的一方用joinColumn
orphanRemove一的一方用这个: orphanRemove=true
以上为个人经验,希望能给大家一个参考,也希望大家多多支持。
原文链接:https://blog.csdn.net/JsongNeu/article/details/105233824
查看更多关于jpa实体@ManyToOne @OneToMany无限递归方式的详细内容...