1

I am using rest services with spring data . when i get data from single table its return proper result in json format . but when i use many to many association between entities using hibernate i am getting an un acceptable result with following error in chrome's console .

Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING

My result looks like there just one row repeating itself , and its a particularly that field which is being used in new generated table by association.

[{"id":7,"name":"Milk pack","description":"haleeb","imageUrl":"milk.jpg","price":350.00,"category":null,"orderDetail":[]},{"id":8,"name":"oil","description":"olive oil ","imageUrl":"/resources/uploads/olive.png","price":670.00,"category":null,"orderDetail":[{"id":263,"productlist":[{"id":10,"name":"Mobile","description":"awesome design, slim design ","imageUrl":"/static/uploads","price":34569.00,"category":null,"orderDetail":[{"id":263,"productlist":[{"id":10,"name":"Mobile","description":"awesome design, slim design ","imageUrl":"/static/uploads","price":34569.00,"category":null,"orderDetail":[{"id":263,"productlist":[{"id":10,"name":"Mobile","description":"awesome design, slim design ","imageUrl":"/static/uploads","price":34569.00,"category":null,"orderDetail":[{"id":263,"productlist":[{"id":10,"name":"Mobile","description":"awesome design, slim design 
.
.
.and so on

My entities are following

Product table

@ManyToMany(mappedBy = "productlist")
private List<OrderDetail> orderDetail =new ArrayList<OrderDetail>();

OrderDetail table

@ManyToMany
@JoinTable(
        name="order_detail_productlist",
        joinColumns=@JoinColumn(name="order_detail_id", referencedColumnName="id"),
        inverseJoinColumns=@JoinColumn(name="productlist_id", referencedColumnName="id"))
private Set<Product> productlist = new HashSet<Product>();

I am using spring data jpa repository to get them

List<Product> findAll();

Note: which products those are not ordered yet that are working properly

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
naila naseem
  • 577
  • 3
  • 12
  • 21

2 Answers2

2

You need the all log for the information, it maybe cause by loop when with jackson. So you need add @JsonIgnoreProperties.Please see http://stackoverflow.com/questions/3325387

user3172755
  • 137
  • 1
  • 10
1

My Problem is solved by using jackson 2.0 documentation

by Adding following annotation or OrderDetail table

@JsonBackReference

it breaks loop and show result properly

naila naseem
  • 577
  • 3
  • 12
  • 21