Part 2 - Infinite RecursionStackOverflow Problem Solved in JPA
HTML-код
- Опубликовано: 10 сен 2024
- Infinite RecursionStackOverflow Problem Solved in JPA using
JsonManagedReference,
JsonBackReference,
JsonIdentityInfo
Subscribe Kindson The Tech Pro RUclips: bit.ly/2PpJd8Q
Join my group ICS on Facebook: bit.ly/2UULiQj
Follow me on Instagram - / kindsonm
Connect with me on LinkedIn: / kindson
Follow me on Twitter: / kindsonm
Learn about me: www.kindsontheg...
As a jr. dev making his first own application from scratch for work: THANK YOU! I simply didnt know about the annotation! Big help!
Wow bro lovely, I was running over the internet all over but did not find the solution.... Amazing bro, thankk you so much
I'm Brazilian, you helped me a lot, thank you
Thank you so much . I just have a question. Can it work for more than one relationship, that is, if this same departments table were related to the Professors table, can you use the @JsonBackReference and @JsonManagedReferences annotations for these tables?
You're the best, thanks so much! Subscribed!
Information is apt for this topic!!
My pleasure 😊
I'm using jsonidentify but i still got problem with many to one relation, when i show json data from the child, the parent data still repeat it's child list , i want to remove it, please help me
Thanks my bro... You have earned the sky
Hi, thanks for this tutorial. please which database are you using? please can you make a video on how u link it on spring?
Emmanuel Imhontu , see here ruclips.net/video/lJQoLIK8LQQ/видео.html
Very good stuff! Congrats!
Thanks!😊
This video helped me a lot Thanks really perfect
Thanks so much! great video
Glad it was helpful!
Hello in case of microservices we have to put annotation on DTOS or Entity?
Спасибо
Thanks so much. The video is really informational. I have a doubt, will this apply for one to one bidirectional relationships also
It works for bi-relationships as well
@@KindsonTheTechPro hey I wanted to know if it works for one to one mapping also?
does it work on files that have multiple one to many and many to one relationship?
This is an interesting question! I'll check
i am getting only id values instead of complete object please help me..
Check your getters and setters. Also check you have two constructors. Let me know the outcome
Thanks so much! great video but how could you solve this problem with many to many relation? I'd appreciate very much your answer :)
the solution above stops the recursive loop error.... but with many-to-many, it gives a nested feedback ... which DOSE solve the problem but provides another :)
Amazing job!!!
Hey is there any way to do this without any extra annotation, because in my previous company my manager use to do bi-directional mapping with any extra annotation, and all data was coming perfectly.
write your custom methods for saving
Thanks for the solution.
Happy to help😊
Thank you very much, I'm Brazuca and you helped me a lot
You just saved me!
Hello sir, I am getting same issue with many-to-many relationship with composite primary key in jpa using third table
Can you please suggest how to resolve this issue
Did you fix it yet? I have the same problem!
Thanks so much :))
My pleasure 😊
it was very useful..Thank a lot !!!..
You are welcome!
thanks!
sir please make font large so mobile user can see easily
@JsonIgnore
😊
LOMBOK USERS: If you're scratching your head because none of this works, it's because of Lombok! It's generating .toString, .equals, and .hashCode methods in the Student class that calls these same methods in the Department class, which in turn calls the Student methods and on and on!
The solution is to put the following annotations above the department property in Student class:
@ToString.Exclude
@EqualsAndHashCode.Exclude
That will omit the company property from these methods, breaking the recursion loop. Hope this helps!
Hi Kindson,
can you please help me solve this because it is not working for me, if there is any setting required please let me know. thanks in advance.
@Data
@Entity
@Table(name = "address")
public class Address {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name ="address")
private String address;
@ManyToOne
@JoinColumn(name = "user_id")
@JsonBackReference
private User user;
}
@Data
@Entity
@Table(name = "user")
public class User {
@Id
@Column
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
@Column(name ="username")
private String name;
@OneToMany( mappedBy = "user", cascade = CascadeType.ALL, targetEntity = Address.class)
// @JoinColumn(name = "user_id", referencedColumnName = "id")
@JsonManagedReference
private Set addresses = new HashSet();
}