Тёмный

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

Don Hash
Подписаться 891
Просмотров 17 тыс.
50% 1

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...

Опубликовано:

 

6 янв 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 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 :)!
@336_gyanendrasingh6
@336_gyanendrasingh6 2 года назад
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 Год назад
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.
@sanjeewanayanananda9657
@sanjeewanayanananda9657 4 года назад
you saved my day brother! many thanks!!
@himanshujain718
@himanshujain718 2 года назад
No reason for dislike thank s lot
@sangtv_AK
@sangtv_AK 3 года назад
Thank you for sharing your knowledge.
@mariaceciliareyes6606
@mariaceciliareyes6606 2 года назад
Muchassss gracias, justo resolviste el problema que tenía, estoy feliz :)
@aniketsengupta2847
@aniketsengupta2847 2 года назад
This video really helped me a lot i was stuck a point and i needed this. thank you so much
@mohittyagi6694
@mohittyagi6694 3 года назад
Thanks buddy. I was stuck in this recurssion thing.
@naraharig1625
@naraharig1625 2 года назад
Really cool bro for these we have used association separate table to map but these looks like overcome earlier implementation
@jorgevillafuerte4895
@jorgevillafuerte4895 3 года назад
it worked for me. thanks!
@roqeebmusibawu6710
@roqeebmusibawu6710 Год назад
Thanks man, it works like magic👍
@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.
@preyas2198
@preyas2198 3 года назад
Amazing explanation ..... Keep it up & help us ..
@isaacbenitez4208
@isaacbenitez4208 Год назад
Bro, thank you so much this is what i was looking for,
@user-cb6st9fq6p
@user-cb6st9fq6p 3 года назад
Thank you a lot bro problem solved.
@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 :)
@SergiuIoan99
@SergiuIoan99 3 года назад
Thank you!
@vicentenascimento5983
@vicentenascimento5983 3 года назад
It helps me a lot
@navjotsinghsaund1014
@navjotsinghsaund1014 2 года назад
Thanks a lot!
@richard321
@richard321 3 года назад
thank you!
@cristiancruz6930
@cristiancruz6930 Год назад
THANK YOU I LOVE U!
@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
@sorapallivenkatesh3280
@sorapallivenkatesh3280 4 года назад
Nice video buddy
@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.
@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 ?
@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
@prasannakumar-kx8uw
@prasannakumar-kx8uw 3 года назад
super bro....
@raghunvlogs
@raghunvlogs Год назад
nice one
@buudanghoang8463
@buudanghoang8463 2 года назад
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)
@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.
@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?
@deepakrajs3860
@deepakrajs3860 4 года назад
Bro how to solve same problem for many to many
@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 ?
@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
@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.
@CyberneticEagle
@CyberneticEagle Год назад
If i use lombok in my project, how to apply it to solve the infinity recursive issue?
@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?
@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?
@aashimaagarwal7521
@aashimaagarwal7521 3 года назад
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 3 года назад
Thanku sir..u saved my day!! :)
@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; } }
@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 10 месяцев назад
Have you got the solution? I'm also in the same situation.
@forinda
@forinda Год назад
I have many to many aond it's not back populating how can I solve this. TThis video was lit
@FaheemIlahi
@FaheemIlahi 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
@FaheemIlahi
@FaheemIlahi 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
@FaheemIlahi
@FaheemIlahi 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 года назад
@@FaheemIlahi Can you answer this question
@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?
@kvnagendra5354
@kvnagendra5354 2 года назад
Remove background music bro
@vijayvishwakarma3844
@vijayvishwakarma3844 Год назад
Please don't run background music
@anktmshr
@anktmshr 2 года назад
bgm is not necessary
@rafaathzanar1414
@rafaathzanar1414 3 месяца назад
@saravanakumar.v9564
@saravanakumar.v9564 2 года назад
Bro in my case , I am using Lombook to generate my getters .Then how could i add that annotation
Далее
Frank Now VS Then Edit 🥵| #brawlstars #shorts
00:18