0

I'm attempting to develop a Spring Boot application and felt that the structure of my data necessitated several @ManyToMany relationships throughout the code. As such, I've run into an error concerned with infinitely recursive JSON after making a query.

The relationships primarily stem from this file: https://github.com/JakeChvatal/scheduleneu/blob/master/src/main/java/scheduleneu/model/Classes.java

So far, I've tried adding @JsonBackReference and @JsonManagedReference annotations to the various Many to Many relationships (with the relationship in charge having the @JsonManagedReference). However, my code is still exhibiting this error.

How can I avoid this recursive data issue?

This error is visible on the live website here: https://scheduleneu.herokuapp.com/api/classes/all

I'd also appreciate advice on general coding practices and style - I'm relatively new to Spring Boot and web development and am unsure of the conventions.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
jakeisnt
  • 1
  • 2
  • Most probably a duplicate of https://stackoverflow.com/questions/37392733/difference-between-jsonignore-and-jsonbackreference-jsonmanagedreference/37394318 Take a look to the question in the link and also try to annotate class_attributes in the Attribute class with JsonManagedReference, if that doesn't help then try a different approach and use JsonIgnore to the "parent-properties" in the "child-classes" – Christos Karapapas Apr 14 '19 at 20:41
  • You can use JsonIgnore on the properties to suppress the relationship properties. Also you can annotate your entities with JsonIdentityInfo or use custom serializers. This http://appsdeveloperblog.com/infinite-recursion-in-objects-with-bidirectional-relationships/ might help. – nkengbeza Apr 14 '19 at 21:47

0 Answers0