由于您在实体中使用@JsonBackReference
onCustomer
属性,因此Loan
该Customer
对象将不包含在序列化中。使用@JsonManagedReference
了Customer
在Loan
对象和使用@JsonBackReference
上Loan
的物业Customer
实体。
这将序列化Customer
您的Loan
实体的属性。但是Customer
对象序列化将不包含该Loan
属性。您需要选择关系的一侧进行序列化。
要允许双方,请@JsonIdentityInfo
在您的实体中使用注释,然后删除@JsonBackReference
和@JsonManagedReference
。您的实体将类似于:
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "customerId")
public class Customer implements Serializable {
...
}
的property
的@JsonIdentityInfo
参考您的实体ID属性,Customer
这将是customerId
。为此Loan
,Item
也。