想分享有关使用杰克逊使用 oneToMany 映射序列化对象并以字符串格式给出响应的知识,
我的班级结构:
@Entity
public class Order {
/*
All the fields associated with this class
*/
@OneToMany(fetch = FetchType.EAGER, mappedBy = "orderId")
private Set<OrderDetails> orderDetails;
//Getters for all properties defined in this class as jackson would depend on this thing
}
在我的情况下,我使用的是 textWebSocket,它只需要字符串格式的消息,所以我需要序列化对象并推送到客户端,我依靠更快的杰克逊来做到这一点,就这样,