Wanted to share this knowledge on using jackson to serialize object with oneToMany mappings and give the response in a string format,
My Class Structure :
@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
}
In my case I am using a textWebSocket which is expecting a message only in String format so I need to serialize the objects and push to the client, I am depending on faster jackson to do it and here it goes,