JPA Bidirectional Mapping Tested With PostMan (Infinite Recursion Problem Solved)

  Рет қаралды 16,814

Don Hash

Don Hash

4 жыл бұрын

This tutorial will help you to understand bidirectional mapping in spring JPA and how it works. Also, you will know how to solve the infinite recursion problem due to bidirectional mapping. Also, I have used POSTMAN to create and retrieve data to test our application.
Code at github - github.com/lahiruhashan/Sprin...

Пікірлер: 72
@sorayanfurter
@sorayanfurter 2 жыл бұрын
I REALLY CAN'T THANK YOU ENOUGH. I've been trying to understand and find a solution to this for daaaaaays. It's 2am on a Saturday and I'm going to bed with a smile on my face. Thank you so much ❤❤❤❤
@iananeri6255
@iananeri6255 3 жыл бұрын
I watched a lot of tutorials but only this one solved the problem
@hichris888
@hichris888 Жыл бұрын
Thank you so much. I've been stuck for about 2 days on a problem and this fixed it :)!
@aniketsengupta2847
@aniketsengupta2847 3 жыл бұрын
This video really helped me a lot i was stuck a point and i needed this. thank you so much
@336_gyanendrasingh6
@336_gyanendrasingh6 3 жыл бұрын
Thank you so much for this video. Great tutorial. Helped me a lot. I was stuck on this problem from last week. So thanks to you i just solved it . Please make more tutorial on springboot and junit test. Great Help.
@TheZainakhtar
@TheZainakhtar 3 жыл бұрын
Thank you so much making this video. I wasn't logging properly thus couldn't identify the root cause. Thanks a tonn
@nagtilakmahesh2860
@nagtilakmahesh2860 2 жыл бұрын
Thank you so much for this video,i was facing issue of adding data in one to many bi-directional relationship through postman also that recursion problem was not getting solved ,you saved my lots of time.
@mohittyagi6694
@mohittyagi6694 3 жыл бұрын
Thanks buddy. I was stuck in this recurssion thing.
@mariaceciliareyes6606
@mariaceciliareyes6606 3 жыл бұрын
Muchassss gracias, justo resolviste el problema que tenía, estoy feliz :)
@naraharig1625
@naraharig1625 2 жыл бұрын
Really cool bro for these we have used association separate table to map but these looks like overcome earlier implementation
@sanjeewanayanananda9657
@sanjeewanayanananda9657 4 жыл бұрын
you saved my day brother! many thanks!!
@isaacbenitez4208
@isaacbenitez4208 Жыл бұрын
Bro, thank you so much this is what i was looking for,
@sangtv_AK
@sangtv_AK 3 жыл бұрын
Thank you for sharing your knowledge.
@roqeebmusibawu6710
@roqeebmusibawu6710 2 жыл бұрын
Thanks man, it works like magic👍
@jorgevillafuerte4895
@jorgevillafuerte4895 3 жыл бұрын
it worked for me. thanks!
@marouencherif7069
@marouencherif7069 3 жыл бұрын
I want really to thank you for saving me :D great work
@aresvincent2773
@aresvincent2773 3 жыл бұрын
pro trick : watch series on InstaFlixxer. Been using them for watching all kinds of movies these days.
@lachlancedric5058
@lachlancedric5058 3 жыл бұрын
@Ares Vincent definitely, have been using instaflixxer for years myself :)
@sahilmudgal9146
@sahilmudgal9146 3 жыл бұрын
thanx a ton brother...i was feeling helpless..solved the issue after 5 days
@DonHash
@DonHash 3 жыл бұрын
I'm glad this helped you.
@user-cb6st9fq6p
@user-cb6st9fq6p 3 жыл бұрын
Thank you a lot bro problem solved.
@cristiancruz6930
@cristiancruz6930 Жыл бұрын
THANK YOU I LOVE U!
@preyas2198
@preyas2198 3 жыл бұрын
Amazing explanation ..... Keep it up & help us ..
@navjotsinghsaund1014
@navjotsinghsaund1014 2 жыл бұрын
Thanks a lot!
@vicentenascimento5983
@vicentenascimento5983 3 жыл бұрын
It helps me a lot
@himanshujain718
@himanshujain718 2 жыл бұрын
No reason for dislike thank s lot
@SergiuIoan99
@SergiuIoan99 3 жыл бұрын
Thank you!
@richard321
@richard321 3 жыл бұрын
thank you!
@sorapallivenkatesh3280
@sorapallivenkatesh3280 4 жыл бұрын
Nice video buddy
@nguyenvinhquang6872
@nguyenvinhquang6872 3 жыл бұрын
Hi, in the infinite loop case, is it okay if I put the @JasonIgnore above the property book? P/s: thanks for the work
@raghunvlogs
@raghunvlogs Жыл бұрын
nice one
@buudanghoang8463
@buudanghoang8463 3 жыл бұрын
Can you add new Book after that? After putting those two annotaions, i can't add new entity in parent-side (Book entity in your situation)
@sudarshanrbhat7686
@sudarshanrbhat7686 3 жыл бұрын
thanks alot bro. I have a doubt could tell me , if we are using @OneToOne mapping, how to pass data through postman ?
@RohitSingh-ko2cz
@RohitSingh-ko2cz 2 жыл бұрын
In Postman when you run review api. you also getting all column data of book table but i want only bookid colum in in review api output. how can prevent other book data except bookid in review api output. plz reply me....
@DonHash
@DonHash 2 жыл бұрын
You need to add only the book ids to the response from back end (spring boot). You can map only the book id from book details there.
@RohitSingh-ko2cz
@RohitSingh-ko2cz 2 жыл бұрын
@@DonHash i only used unidirectional manytoone in review table and bookid is forign key in review table. how can i only map bookid. plz send me any refeernce for this.
@ROCKSDOT
@ROCKSDOT 2 жыл бұрын
Is that a bi directional OR two uni directional ? Also, u entered the bookId while posting reviews...there..will hibernate automatically takes that id or need to write code manually ?
@giribabudevalla7356
@giribabudevalla7356 3 жыл бұрын
Hi , when i use one to one bidirectional mapping with spring boot rest api.i got the same issue.kindly help me to fix it.
@CyberneticEagle
@CyberneticEagle Жыл бұрын
If i use lombok in my project, how to apply it to solve the infinity recursive issue?
@ajaypatl8372
@ajaypatl8372 3 жыл бұрын
after the used of Annotation jsonBackReferance and JsonManageReferance it will give problem to post the data ....it shows the error please help....
@DonHash
@DonHash 3 жыл бұрын
What's the error?
@lazraksiwar9947
@lazraksiwar9947 4 жыл бұрын
i have a problem: object references an unsaved transient instance - save the transient instance before flushing : com.pfe.Model.SousModule.module -> com.pfe.Model.Module
@lazraksiwar9947
@lazraksiwar9947 4 жыл бұрын
@@DonHash thank you
@prasannakumar-kx8uw
@prasannakumar-kx8uw 3 жыл бұрын
super bro....
@irtazanadeem566
@irtazanadeem566 2 жыл бұрын
after resolving the infinite recursion you still get a reviews in book object why ? the lazy loading is not working I think, what if you have thousands of reviews of one book your code which fetch reviews automatically. my basic question is why fetching child's automatically if you request for just books?
@deepakrajs3860
@deepakrajs3860 4 жыл бұрын
Bro how to solve same problem for many to many
@SiddheshChampaneri
@SiddheshChampaneri 4 жыл бұрын
you made it seem easy!!! but what happens when you work with complex native query and working with relations in only one entity
@saisurajprathigadapa8121
@saisurajprathigadapa8121 4 жыл бұрын
Even I have the same question that I have a situation where I need to provide both employee and department details in bidirectional way I can't take one side because I have two use cases where getEmployees should return employees with department and getDepartment should return all departments with employee data .....both scenarios without recursion?
@saisurajprathigadapa8121
@saisurajprathigadapa8121 4 жыл бұрын
@@DonHash Thanks for responding I'll give it a try.
@user-wy4el6zu1f
@user-wy4el6zu1f 3 жыл бұрын
I have the same question. I only see reply from the viewer. Your answer @don is not visible to me.
@nurullahdemirel6250
@nurullahdemirel6250 2 жыл бұрын
Hello I have one to one relation between User and Adress entity , When I get all users ı m getting with adress but when ı all adress ,ı can not get user with address. Hoıw can ı do this ?
@saurabh7575
@saurabh7575 11 ай бұрын
Have you got the solution? I'm also in the same situation.
@shivanisinghal1641
@shivanisinghal1641 3 жыл бұрын
what if i am adding @getter @setter where should i write @jsonbackreference plz reply plz
@DonHash
@DonHash 3 жыл бұрын
You mean if you using lombok or something like that? If that's the case you can provide your own getXXX, and then use AccessLevel.NONE to tell Lombok not to generate the getXXX: @Data public class OneOfPaddysPojos { // ... other fields ... @Getter(AccessLevel.NONE) private Boolean XXX; public Boolean isXXX() { return XXX; } }
@Gorky25
@Gorky25 3 жыл бұрын
Hi, Thanks for the video and example. I have one similar question. I have entity Student and entity Town. When I create a student I have to create his town or to call by id from DB if already exists. But when I create a new town I don't need to create a student. This is my code: public class StudentEntity { ... @NotNull @ManyToOne(fetch = FetchType.LAZY) private TownEntity townEntity; ... } public class TownEntity { .... @OneToMany(mappedBy = "townEntity", cascade = CascadeType.ALL) private List students; ... } When I send POST over postman I don't need students, right? { "townName": "New York", "postalCode": "10018", "municipality": "New York", "address": "Address 123", "students": { } } Is this code good?
@Gorky25
@Gorky25 3 жыл бұрын
@@DonHash Did I write well that code? I will test it tomorrow. Do you have some suggestions to improve my code? When I remove a town I don't want students to be removed. In that case, is this relationship good?
@forinda
@forinda Жыл бұрын
I have many to many aond it's not back populating how can I solve this. TThis video was lit
@aashimaagarwal7521
@aashimaagarwal7521 4 жыл бұрын
Hi Sir, Can u tell me how to TEST many to many relationship with Postman , I mean how to create Json request for Many to Many relationship type and how to handle tht in controller. I am stuck in that part. e.g. I am taking for this is Students and Subjects. Thanku in advance !!
@aashimaagarwal7521
@aashimaagarwal7521 4 жыл бұрын
Thanku sir..u saved my day!! :)
@0DarkPrince0
@0DarkPrince0 3 жыл бұрын
I am facing problem with one to many and many to one mapping. can you help me to understand this? Please it means a lot for me. Thanks in advance
@0DarkPrince0
@0DarkPrince0 3 жыл бұрын
@@DonHash thats not my problem. You saved 2 objects in database one by one. I want to save like this { "firstName": "Sonali", "lastName": "Tiwari", "employeeDetail":{ "phoneNumber": "9219316099", "address": "Kanpur", "gender": "Female", "birthdayDate": "1993-04-18" } } OneToMany
@0DarkPrince0
@0DarkPrince0 3 жыл бұрын
what should our controller code? it throws few exceptions if I run my code. I have tried many times but the same issue I am getting every time. and what table fetch type should be Eager and which one is lazy. or I have to put lazy on both sides.
@dineshpavithra
@dineshpavithra 3 жыл бұрын
@@0DarkPrince0 Can you answer this question
@kvnagendra5354
@kvnagendra5354 2 жыл бұрын
Remove background music bro
@Paradise-kv7fn
@Paradise-kv7fn 4 жыл бұрын
I dont get it...i have seens loads of solutions to this problem...and yes there are multiple ways to solve this problem like jsoningore,the way you showed etc...but using these methods, we will not be able to get the parent details from the child....in essence, we are more or less converting the relationship as unidirectional which defeats the purpose of making it bidirectional in the first place
@Paradise-kv7fn
@Paradise-kv7fn 4 жыл бұрын
@@DonHash so can you tell me how can we get the parent info from the child entity after using these annotations?
@vijayvishwakarma3844
@vijayvishwakarma3844 Жыл бұрын
Please don't run background music
@anktmshr
@anktmshr 2 жыл бұрын
bgm is not necessary
@saravanakumar.v9564
@saravanakumar.v9564 2 жыл бұрын
Bro in my case , I am using Lombook to generate my getters .Then how could i add that annotation
@rafaathzanar1414
@rafaathzanar1414 4 ай бұрын
Association Mapping - One-To-Many Bidirectional Join column
18:49
Best Toilet Gadgets and #Hacks you must try!!💩💩
00:49
Poly Holy Yow
Рет қаралды 22 МЛН
Pleased the disabled person! #shorts
00:43
Dimon Markov
Рет қаралды 31 МЛН
ПРОВЕРИЛ АРБУЗЫ #shorts
00:34
Паша Осадчий
Рет қаралды 7 МЛН
路飞太过分了,自己游泳。#海贼王#路飞
00:28
路飞与唐舞桐
Рет қаралды 38 МЛН
Part 2 - Infinite RecursionStackOverflow Problem Solved in JPA
11:26
Kindson The Tech Pro
Рет қаралды 13 М.
JAVA DTO Pattern Tutorial | Simplify Your Code
19:12
Amigoscode
Рет қаралды 197 М.
10 Spring and Spring Boot Common Mistakes You Need To STOP
15:49
Amigoscode
Рет қаралды 145 М.
Coding HacksTo Boost The Java Code Performance - Part 1
19:07
Data Insertion In @ManyToMany Relationship In Spring Data JPA
13:54
Best Toilet Gadgets and #Hacks you must try!!💩💩
00:49
Poly Holy Yow
Рет қаралды 22 МЛН