Home > other >  What are the best practices for resolving jpa bidirectional circular references?
What are the best practices for resolving jpa bidirectional circular references?

Time:11-30

What are the best practices for resolving JPA bidirectional circular references?

I experienced an error falling into infinite recursion due to JPA bidirectional circular reference.

At this time, it was said that the problem could be solved in the following way.

  1. Ignore using @JsonIgnore -> I ruled out this option because I need all the data.

  2. Use @JsonBackReference, @JsonManagedReference. -> Currently, I have solved my problem using this method.

I'm wondering if there's a better way to solve the problem, so I'm leaving a question like this.

best regards!

CodePudding user response:

@JsonBackReference and @JsonManagedReference are semantically correct.

@JsonIngore not.

Checkout this article: https://www.baeldung.com/jackson-bidirectional-relationships-and-infinite-recursion

CodePudding user response:

your case object is calling inner object and inner object calling object so,Remove getter methods from inner object(one side). i think it works.

  • Related