0

I'm wondering what is the main diffrence between those two annotations? Both are to fight with Infinite recursive loop problem. But in example

Difference between @JsonIgnore and @JsonBackReference, @JsonManagedReference

@varren showed usage of @JsonBackReference and I think that he created Infinite recursive loop as well. Also when I try to use @JsonBackReference, it also creates a recursive loop in contrast to @JsonIgnore? So how can we manage the case of Infinite loop in order to use @JsonBackReference?

Community
  • 1
  • 1
bielas
  • 672
  • 2
  • 12
  • 29
  • Look closely into what actual objects are in varren's answer: there is only single `Player` object (`Player@914`) and single `Info` object (`Info@915`). Please remove your answer from that question as well. – M. Prokhorov Mar 09 '17 at 14:59
  • I deleted it, but your answer doesn't mean for me anything. Can you write it in diffrent words? – bielas Mar 09 '17 at 15:02
  • How else can I describe it? There's no infinite recursion because there is only a single instance of both `Player` and `Info` after deserializing `{id: 1, info: {id: 1}}`. If there was infinite recursion, that example would've produced it, giving error rather than those two objects. Q.E.D. – M. Prokhorov Mar 09 '17 at 15:06
  • But what about the second image, below **But with JsonManagedReference + JsonBackReference we will get Info referance there**? It calls once PLayer once Info, once Player once Info, etc - doesn't it seems like an infinitive loop? – bielas Mar 09 '17 at 15:13
  • On second image, there is only **one** instance `Player@914` and only **one** instance `Info@915`. They both have references to each other, and debugger image displays that *if* you follow links blindly you will get into infinite recursion, **but we did not**, because of `@JsonManagedReference + @JsonBackReference` working. – M. Prokhorov Mar 09 '17 at 15:18
  • Sometimes it's time to take things as they are.. ;) – KLHauser Mar 10 '17 at 17:43

1 Answers1

0

@M. Prokhorov Ok, so what about mine case where I put those two annotations and get something like that:

enter image description here

bielas
  • 672
  • 2
  • 12
  • 29