public class OrderEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="order_id")
private int orderid;
@ManyToOne
@JoinColumn(name="user_id", nullable=false)
private UserEntity user;
@OneToMany(mappedBy="ordersBid",fetch=FetchType.EAGER)
private Set<BidPriceEntity> bidOrders;
}
public class BidPriceEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@ManyToOne
@JoinColumn(name="order_Id",nullable=false)
private OrderEntity ordersBid;
@ManyToOne
@JoinColumn(name="driver_Id",nullable=false)
private UserEntity driver;
@Column(name="bid_price")
private double bidPrice;
}
public class OrderEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="order_id")
private int orderid;
@ManyToOne
@JoinColumn(name="user_id", nullable=false)
private UserEntity user;
@OneToMany(mappedBy="ordersBid",fetch=FetchType.EAGER)
private Set<BidPriceEntity> bidOrders;
}
这是三个实体。我试图将数据(从数据库中检索到)传输到JsonArray。它总是会出错:层次结构中存在一个循环!
我应该如何设置:JsonConfig(setJsonPropertyFilter)属性来摆脱此错误。
循环基本上有两个选择-自己编写序列化程序use @JsonIgnore
。就像在您的代码中-OrderEntity
包含的列表一样BidPriceEntities
,其中又包含对的引用OrderEntity
。标记ordersBid
为@JsonIgnore
,它应该可以工作。在列表序列化中...如果您无权访问该类,请尝试mixins。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句