Spring Data JPA Relationships Tutorial - ManyToMany, ManyToOne & OneToMany

Поділитися
Вставка
  • Опубліковано 7 січ 2025

КОМЕНТАРІ • 127

  • @jhunter34
    @jhunter34 Рік тому +5

    Oddly, this information was very difficult for me to find. I've been stuck trying to figure out how to configure the relationships between entities until I found this video. It was clear, concise, and best of all, my code is now working. Much appreciated Kris!

  • @g2svnit
    @g2svnit 7 місяців тому +2

    Detailed, clear and concise tutorial, hard to find such straightforward learning.

  • @lkriswheeler
    @lkriswheeler 3 роки тому +6

    Very helpful! I was playing with JPA and kept having the infinite recursion problem with my many-to-many relations and hadn't even though the REST controllers. I watched this and fixed my backend. Great job!

    • @KrisFoster1
      @KrisFoster1  3 роки тому +1

      That's great, nice name, Kris!

  • @stevegathara8885
    @stevegathara8885 Рік тому

    The fisrt best tutorial i have come across . It's hitting the nail on the head at the right time for me. Thannks so much teacher.

  • @imiims6017
    @imiims6017 2 роки тому +10

    Fantastic tutorial. I was has the recursion issue and this fixed it right up! Very good tutorial with brilliant explanations. Thank you! You should do a Udemy course in Spring

  • @santiagotorres8680
    @santiagotorres8680 3 роки тому +8

    this is the best video explaining jpa relationships!!! Thank you soo much for sharing your knowledge :)

    • @KrisFoster1
      @KrisFoster1  3 роки тому +1

      Thank you for the kind feedback and glad you enjoyed!

  • @nidhalsadfi7984
    @nidhalsadfi7984 2 роки тому

    thank you so much sir this saved my life am stuck in my project for like 3 days in the many to many and u just saved me thank you dear sir

  • @StarContract
    @StarContract Рік тому +1

    Great tutorial - short, concise, clear and with practical examples.

  • @kotikobillionaire281
    @kotikobillionaire281 2 роки тому

    I think this is the most useful resource on spring relationships

  • @veereshdeepak9466
    @veereshdeepak9466 2 роки тому

    I got my 100% of doubts cleared by this vedio. Its just crystal clear ❤️

  • @moaazsuliman7584
    @moaazsuliman7584 2 роки тому

    From Egypt : You are my hero with good explanation❤♥♥♥♥

  • @ryanhill101
    @ryanhill101 3 роки тому +4

    Another great spring boot video Kris.

    • @KrisFoster1
      @KrisFoster1  3 роки тому

      @Ryan Hill thanks for the feedback & glad you enjoyed!

  • @MrVipulLal
    @MrVipulLal 2 місяці тому

    Great tutorial. To the point and clearly explained. Thanks!

  • @yashgaikwad7134
    @yashgaikwad7134 3 роки тому +1

    I WANNA THANK YOU A MILLION TIMES FOR THIS VIDEO. VERY VERY VERY HELPFUL !!!!!

  • @pekzasuccess9334
    @pekzasuccess9334 2 роки тому

    I'm sharing this tutorial with all my colleagues. Amazing!

  • @josuealejandromedinaguerre7010

    Gracias por impartir todos tus conocimientos, al fin entendí cómo hacer relaciones con JPA.

  • @georgenady7375
    @georgenady7375 2 роки тому

    very clear and going to point easly than others
    I recomend any one how wants to learn ERD in a smiple way
    from that toturial

  • @riccardod.888
    @riccardod.888 2 роки тому

    Thank you, I needed to refeersh a bith JPA relationships and this video is very well done.

  • @diegoruiz5265
    @diegoruiz5265 3 роки тому +1

    Awesome video Kris ! It was so useful to me ! Thanks a lot !

    • @KrisFoster1
      @KrisFoster1  3 роки тому +1

      Glad you enjoyed @Diego Ruiz, thank you for the feedback!

  • @maminesoulymane9023
    @maminesoulymane9023 3 роки тому +1

    very useful video and well explained, thanks a lot Kris

  • @nr4o1981
    @nr4o1981 3 роки тому +1

    This helped me but I think I need a REST example but this sure helped so appreciated!

  • @lakshminarayana9189
    @lakshminarayana9189 3 роки тому +1

    Very decent explantion Kris....Thanks for that😊

    • @KrisFoster1
      @KrisFoster1  3 роки тому

      Thank you for the feedback @Lakshmi Narayana

  • @emreaka3965
    @emreaka3965 3 роки тому +10

    I did everything the same but i still take an error about recursion :( I used List rather than using Set and my problem is solved. Thank you by the way. I was looking a tutorial like this. I spent all of my day on internet to learn how to create a relationship between my tables.

    • @faizatasneem3814
      @faizatasneem3814 2 роки тому

      Thank you so much 💖

    • @WABNII
      @WABNII Рік тому

      Probably you had repeated data in set. Set don't accept repeated data, but, list accept it.

  • @ramabookstroremalang9131
    @ramabookstroremalang9131 2 роки тому

    Kris Foster is my new Hero!

  • @joaodelfino4124
    @joaodelfino4124 2 роки тому

    Great video! It really helped me to create the relationships on my database. Thanks a lot!

  • @rajamanis4545
    @rajamanis4545 3 роки тому +2

    Good Explanation. Keep going mate!

    • @KrisFoster1
      @KrisFoster1  3 роки тому +1

      Thank you for the kind feedback @Raja Mani!

  • @nemanjaraven888888
    @nemanjaraven888888 3 роки тому +3

    Nice ,really nice...you just got a new subscriber:)

  • @sajis79
    @sajis79 3 роки тому

    That was nicely explained tutorial. Thanks. Create more of this kind.

  • @FahaadAbbadi
    @FahaadAbbadi 2 місяці тому

    Thanks a lot for this video, I enjoyed it and learned a lot from it

  • @bashirulagoke684
    @bashirulagoke684 16 днів тому

    Currently I’m having an issue mapping columns from two different entities to the database I created in MySql. The annotations are correct and all the dependencies are allocated to the pom.xml file. There is a connection with the workbench client and the server is running. However, there are still red lights under on the columns annotations names I’ve selected.
    I try selecting each column a placing them into the single data source but it is not working ?

  • @KeepOfTheLight312
    @KeepOfTheLight312 3 роки тому

    Thanks, Dude! Your tutorial helped me completed my task ))

  • @sinurao1017
    @sinurao1017 3 роки тому +1

    well explained kris and nice tutorial

    • @KrisFoster1
      @KrisFoster1  3 роки тому

      Thank you for the feedback, glad you enjoyed!

  • @twiincentral8780
    @twiincentral8780 3 роки тому

    Thanks so much. This was really great to understand the relationships

  • @goofyTavern
    @goofyTavern 3 роки тому +1

    Good Material for JPA . Good job 👌

  • @mercy1ish
    @mercy1ish 2 роки тому +1

    Hi Kris, your video was super helpful to fix my relationship mapping in the backend, but now I need to implement it in Angular . Would please make a video on how to implement that in Angular ?

  • @ravindranadhyandrapu6822
    @ravindranadhyandrapu6822 3 роки тому +6

    if it was a movie it can get a oscar nomination ❤️. Thank you for making us understand relationships easy. Could you please give us sample how we structure rest controller calls prod projects. Thank you

  • @ebubekirgunerhanal197
    @ebubekirgunerhanal197 3 роки тому +2

    Thank you, well done it was a great explanation.

  • @ariel_chess
    @ariel_chess Місяць тому

    How does it know the column where it has to put the user id. Does it deduce it from the string?

  • @drawioartist608
    @drawioartist608 3 роки тому

    Came here by coincidence. Now I'm permanently here

  • @programming7844
    @programming7844 2 роки тому

    Why not divide packages with controllers, services, repositories and models? And why use Autowired annotation instead of the better constructor injection solution?

  • @ranjiththangaraju
    @ranjiththangaraju 3 роки тому +1

    Thanks kris!! Really Helpful!!

    • @KrisFoster1
      @KrisFoster1  3 роки тому

      I'm glad it helped, thank you for watching!

  • @elainelif
    @elainelif 3 роки тому

    thank you so so so so so much for this video, it helped me a lot.

  • @switch1e
    @switch1e 2 роки тому

    Is there a way to have a teacher assigned to the subject from inception?

  • @HungNguyen-kn6vj
    @HungNguyen-kn6vj Рік тому

    It’s very helpful 🎉. Thanks

  • @KieranMueller
    @KieranMueller Рік тому

    Awesome tutorial! Now I just need to figure out how to delete students, teachers, and subjects. I get a 500 error when I try due to violating foreign key constraints.

  • @valmirknasel
    @valmirknasel 3 роки тому

    Another way to solve the recursive problem is to use DTO pattern to present the retrieved data from database instead using JSON ignore!

  • @gokulaher2476
    @gokulaher2476 3 роки тому +1

    The moral of the story is , in short need to create a customer with all dependent objects and data should get stored in the respective tables and when that customer is deleted then all the data related to that customer in the respective table should also get deleted , Thanks

  • @Tapin-vp6zp
    @Tapin-vp6zp 3 роки тому +1

    how to create subjects with a default teacher on post itself? Isn't it possible?

  • @marcodebiase7066
    @marcodebiase7066 2 роки тому

    @Kris Foster I have a question about the ManyToMany. If i want to add the Subject in the Student Set. How would it be? because i get an Exception when i try to save the student with the added subject.

  • @alexoderdenge7229
    @alexoderdenge7229 2 роки тому

    Thank you so much for the tutorial! I was days trying to set up the relationship between my two entities, but I wasn't doing it right, so it wasn't working

  • @johnherrera6896
    @johnherrera6896 3 роки тому +2

    Me salvaste, que gran aporte, saludos

  • @Scoty98
    @Scoty98 3 роки тому +1

    Very good explatation. But I give some issue. When I use everywhere Set bettwen relationship I've got recursion problem. Replacing Set into List in Student class fix problem but I don' t konw why. Some advice ? Thanks to all.

    • @elkamillo123
      @elkamillo123 2 роки тому +1

      Had the same issue, replacing one Set by a List worked for me too. Can't explain why either... but thanks for the hint! :)

    • @daribear
      @daribear 2 роки тому

      @@elkamillo123 Hey, I know this is a late response, but I have spend hours researching this and I think I have the reason. Apparently it is not good practice to use Lists, as they don't perform well and they could lead to other issues. The reason we are all having this problem is due to lombok. If you remove the @data annotation, and create getters and setters , I believe you can then use the @JSONIgnore annotation, which will then allow you to stop using lists! Hope this helps!

  • @Omer-fr1ze
    @Omer-fr1ze 3 роки тому

    Hello, great video! I am curious about what happens if I do not initialize Set and leave like this 'Set students;' Can you explain me please?

  • @cevaponomaryov9044
    @cevaponomaryov9044 2 роки тому

    You really help me thank you ❤️

  • @Nicholas2703
    @Nicholas2703 3 роки тому +1

    subbed and looking forward to more

  • @manavithorve7422
    @manavithorve7422 3 роки тому

    I want to know how can we send the list of subjects in a single request using request body and how we'll assign it to student

  • @rahatkhemissi8733
    @rahatkhemissi8733 2 роки тому

    Bravo teacher, just i would have a link fo r the serie of this course please

  • @louaykhemiri5910
    @louaykhemiri5910 3 роки тому +1

    thank you man , it's realy helpfull

  • @NikolayKirilyuk-ym4te
    @NikolayKirilyuk-ym4te Рік тому

    Thanks Bro! It's movie really good!!!

  • @AlassaneMbengue-zy3mn
    @AlassaneMbengue-zy3mn 9 місяців тому

    Very helpful tutorial

  • @chcamp
    @chcamp 2 роки тому

    Hello i understand all examples how be @OneToOne?? one object type in each Class??. Saludos desde Lima - Perú!!

  • @I.amRisky
    @I.amRisky 3 роки тому

    But how do you retrieve a one to many relationship.In this case teacher and subjects

  • @ababhale
    @ababhale 2 роки тому

    I exactly faced the recursion issue, so your video helped a lot to understand root cause.
    In case if we want to retrieve Student with subjects as well then how can we do that ?

    • @dillynlakey6420
      @dillynlakey6420 2 роки тому

      You can just do a select statement on the subject tables.
      Select * subject FROM Table_Name where student-id = 1
      This is just an example so I did not use the correct names. I was to lazy to check.

  • @jalexb503
    @jalexb503 2 роки тому

    Great explanation

  • @benjamine.ndugga729
    @benjamine.ndugga729 3 роки тому

    Hi Mate, can you demo a many to many relationship where a student is drops a subject

  • @12crenshaw
    @12crenshaw 11 місяців тому

    I really don't understand why there's so little about managing relationships when creating rest api. It's bonkers to me. What good is post and user to me, when I can't even display posts of user

  • @skernelman2208
    @skernelman2208 3 роки тому

    Great tutorial, thanks!!

  • @salmayassin671
    @salmayassin671 2 роки тому

    Anyone know how can I getAll subjects for 1 teacher not all subjects?

  • @rolandomamani4561
    @rolandomamani4561 2 роки тому

    Muchas gracias me sirvio mucho tu tutorial

  • @salarystealer
    @salarystealer 3 роки тому

    short and clear, thanks

  • @azamatabdullaev4580
    @azamatabdullaev4580 2 роки тому

    Clear and concise.

  • @luizgustavoghisi8725
    @luizgustavoghisi8725 3 роки тому +1

    thanks bro, i was have, this recursive error for 3 days, you save me. sorry for the english kkk

  • @Satenc0
    @Satenc0 3 роки тому

    The thing is what if you wanna see the subjects of one student? You would need to use the design pattern DTO (Data transfer object) right? Thats what I would do since @JsonIgnore is kind of forcing me to do so, what other solution do you recommend? Nice tutorial =)

    • @dillynlakey6420
      @dillynlakey6420 2 роки тому

      write a select statement to retrieve the data from the join table

  • @dennielluissadian5026
    @dennielluissadian5026 3 роки тому

    Does this include entity graphs? Please answer, I don't want to waste my time.

  • @wantedlepota9960
    @wantedlepota9960 5 місяців тому

    great video mate

  • @gadinaresh5458
    @gadinaresh5458 2 роки тому

    Great video 🔥

  • @reiskoryphae
    @reiskoryphae 3 роки тому

    Note for myself
    19:20

  • @ErmanUtkuavsar
    @ErmanUtkuavsar 10 місяців тому

    Gold, very clear.

  • @dushsam
    @dushsam 3 роки тому

    Well done brother

  • @getpath885
    @getpath885 3 роки тому +1

    Thanks a lot sir

  • @SamirJzVFX
    @SamirJzVFX 2 роки тому

    17:45

  • @V_Smah
    @V_Smah Рік тому

    Thank you a lot!!!

  • @keronz202
    @keronz202 2 роки тому

    Why did you start from many to many relations ? It's hard for beginners to understand. Start from one to one, one to many, many to one, many to many. In this order.

  • @rodrickngonyoku5042
    @rodrickngonyoku5042 3 роки тому

    Nice accent, nice tutorial

  • @hubertharris6874
    @hubertharris6874 Рік тому

    Nice One

  • @fdcendm
    @fdcendm 11 місяців тому

    you are the best !!!

  • @_chrxtopher
    @_chrxtopher 2 роки тому

    Thank youuuuu!!

  • @leekbiel
    @leekbiel Рік тому

    Thank you!

  • @pedrocosta9769
    @pedrocosta9769 3 роки тому +1

    Thanks!

  • @강민준-w1p
    @강민준-w1p 2 роки тому

    영상 잘 봤습니다 :)

  • @murationametisation4347
    @murationametisation4347 2 роки тому

    thank you!

  • @Kapalatus
    @Kapalatus 2 роки тому

    My name is simon :) i like

  • @user-pj2ch4yw5g
    @user-pj2ch4yw5g 2 роки тому

    thanx man

  • @yarik83men51
    @yarik83men51 2 роки тому

    Super

  • @user-pj2ch4yw5g
    @user-pj2ch4yw5g 2 роки тому

    awesome

  • @Justin-xy2ko
    @Justin-xy2ko 2 роки тому

    why are you not Indian????

  • @вахидразбамбеков
    @вахидразбамбеков 2 роки тому

    finally not indian!!!!!

  • @andersonportoS
    @andersonportoS 2 роки тому

    Lindo

  • @JaiKumar-jh7hl
    @JaiKumar-jh7hl 9 місяців тому

    Bad

  • @SailBuddha
    @SailBuddha 3 роки тому

    Great video, I just wish you would have had an example of @Getmapping which would have returned results for a one to many with the the query:
    SELECT a.name "Teacher", b.name "Subjects"
    FROM TEACHER AS a
    JOIN SUBJECT AS b
    ON a.id=b.TEACHER_ID
    And/Or a @Getmapping for the results from the many to many relationship with a filter such as:
    SELECT a.name "Subject", c.name "Student"
    FROM SUBJECT AS a
    JOIN STUDENT_ENROLLED AS b
    ON a.ID=b.SUBJECT_ID
    JOIN STUDENT AS c
    ON c.ID=b.STUDENT_ID
    where a.name='Science'