Spring Data JPA Relationships Tutorial - ManyToMany, ManyToOne & OneToMany

Поделиться
HTML-код
  • Опубликовано: 9 фев 2021
  • Learn how to use Spring Data JPA relationships such as ManyToMany, ManyToOne & OneToMany.
    We create a web application using the spring starter (start.spring.io/). We then expose an API for 3 entities. We then use Spring Data JPA to create relationships between these entities.
    Check out the code on GitHub here: github.com/kriscfoster/Spring...
    Don't forget to Subscribe here: / @krisfoster1
  • НаукаНаука

Комментарии • 122

  • @g2svnit
    @g2svnit Месяц назад +1

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

  • @jhunter34
    @jhunter34 Год назад +4

    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!

  • @StarContract
    @StarContract Год назад +1

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

  • @santiagotorres8680
    @santiagotorres8680 3 года назад +7

    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!

  • @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

  • @pekzasuccess9334
    @pekzasuccess9334 Год назад

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

  • @ryanhill101
    @ryanhill101 3 года назад +3

    Another great spring boot video Kris.

    • @KrisFoster1
      @KrisFoster1  3 года назад

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

  • @yashgaikwad7134
    @yashgaikwad7134 2 года назад +1

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

  • @veereshdeepak9466
    @veereshdeepak9466 2 года назад

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

  • @joaodelfino4124
    @joaodelfino4124 2 года назад

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

  • @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!

  • @sajis79
    @sajis79 3 года назад

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

  • @kotikobillionaire281
    @kotikobillionaire281 Год назад

    I think this is the most useful resource on spring relationships

  • @riccardod.888
    @riccardod.888 Год назад

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

  • @nemanjaraven888888
    @nemanjaraven888888 3 года назад +3

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

  • @twiincentral8780
    @twiincentral8780 2 года назад

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

  • @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

  • @lkriswheeler
    @lkriswheeler 2 года назад +4

    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  2 года назад +1

      That's great, nice name, Kris!

  • @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

  • @adiletkobogonov6248
    @adiletkobogonov6248 3 года назад

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

  • @josuealejandromedinaguerre7010

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

  • @lakshminarayana9189
    @lakshminarayana9189 3 года назад +1

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

    • @KrisFoster1
      @KrisFoster1  3 года назад

      Thank you for the feedback @Lakshmi Narayana

  • @maminesoulymane9023
    @maminesoulymane9023 2 года назад +1

    very useful video and well explained, thanks a lot Kris

    • @KrisFoster1
      @KrisFoster1  2 года назад +1

      Glad you enjoyed, thank you

  • @rajamanis4545
    @rajamanis4545 3 года назад +2

    Good Explanation. Keep going mate!

    • @KrisFoster1
      @KrisFoster1  3 года назад +1

      Thank you for the kind feedback @Raja Mani!

  • @nr4o1981
    @nr4o1981 3 года назад +1

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

  • @moaazsuliman7584
    @moaazsuliman7584 Год назад

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

  • @HungNguyen-kn6vj
    @HungNguyen-kn6vj 10 месяцев назад

    It’s very helpful 🎉. Thanks

  • @ranjiththangaraju294
    @ranjiththangaraju294 3 года назад +1

    Thanks kris!! Really Helpful!!

    • @KrisFoster1
      @KrisFoster1  3 года назад

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

  • @ramabookstroremalang9131
    @ramabookstroremalang9131 2 года назад

    Kris Foster is my new Hero!

  • @skernelman2208
    @skernelman2208 3 года назад

    Great tutorial, thanks!!

  • @AlassaneMbengue-zy3mn
    @AlassaneMbengue-zy3mn 3 месяца назад

    Very helpful tutorial

  • @ebubekirgunerhanal197
    @ebubekirgunerhanal197 3 года назад +2

    Thank you, well done it was a great explanation.

    • @KrisFoster1
      @KrisFoster1  3 года назад

      Thank you, glad you enjoyed!

  • @Nicholas2703PL
    @Nicholas2703PL 3 года назад +1

    subbed and looking forward to more

  • @elainelif
    @elainelif 2 года назад

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

  • @salarystealer
    @salarystealer 3 года назад

    short and clear, thanks

  • @sinurao1017
    @sinurao1017 3 года назад +1

    well explained kris and nice tutorial

    • @KrisFoster1
      @KrisFoster1  3 года назад

      Thank you for the feedback, glad you enjoyed!

  • @azamatabdullaev4580
    @azamatabdullaev4580 Год назад

    Clear and concise.

  • @johnherrera6896
    @johnherrera6896 2 года назад +2

    Me salvaste, que gran aporte, saludos

  • @louaykhemiri5910
    @louaykhemiri5910 3 года назад +1

    thank you man , it's realy helpfull

  • @ErmanUtkuavsar
    @ErmanUtkuavsar 4 месяца назад

    Gold, very clear.

  • @NikolayKirilyuk-ym4te
    @NikolayKirilyuk-ym4te Год назад

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

  • @cevaponomaryov9044
    @cevaponomaryov9044 2 года назад

    You really help me thank you ❤️

  • @goofyTavern
    @goofyTavern 2 года назад +1

    Good Material for JPA . Good job 👌

  • @jalexb503
    @jalexb503 2 года назад

    Great explanation

  • @VitaliiSmahlenko
    @VitaliiSmahlenko Год назад

    Thank you a lot!!!

  • @gadinaresh5458
    @gadinaresh5458 2 года назад

    Great video 🔥

  • @mercy1ish
    @mercy1ish Год назад +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 ?

  • @_chrxtopher
    @_chrxtopher Год назад

    Thank youuuuu!!

  • @rolandomamani4561
    @rolandomamani4561 2 года назад

    Muchas gracias me sirvio mucho tu tutorial

  • @fdcendm
    @fdcendm 5 месяцев назад

    you are the best !!!

  • @leekbiel
    @leekbiel 7 месяцев назад

    Thank you!

  • @dushsam
    @dushsam 3 года назад

    Well done brother

  • @getpath885
    @getpath885 3 года назад +1

    Thanks a lot sir

  • @ravindranadhyandrapu6822
    @ravindranadhyandrapu6822 2 года назад +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

  • @murationametisation4347
    @murationametisation4347 2 года назад

    thank you!

  • @user-kj9xk1cd1z
    @user-kj9xk1cd1z 2 года назад

    영상 잘 봤습니다 :)

  • @hubertharris6874
    @hubertharris6874 9 месяцев назад

    Nice One

  • @alexoderdenge7229
    @alexoderdenge7229 Год назад

    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

  • @user-pj2ch4yw5g
    @user-pj2ch4yw5g 2 года назад

    thanx man

  • @pedrocosta9769
    @pedrocosta9769 3 года назад +1

    Thanks!

  • @Omer-fr1ze
    @Omer-fr1ze 2 года назад

    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?

  • @yarik83men51
    @yarik83men51 2 года назад

    Super

  • @Tapin-vp6zp
    @Tapin-vp6zp 3 года назад +1

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

  • @switch1e
    @switch1e 2 года назад

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

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

  • @drawioartist608
    @drawioartist608 3 года назад

    Came here by coincidence. Now I'm permanently here

  • @yogeshc7241
    @yogeshc7241 Год назад

    awesome

  • @manavithorve7422
    @manavithorve7422 2 года назад

    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

  • @emreaka3965
    @emreaka3965 3 года назад +9

    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.

  • @valmirknasel
    @valmirknasel 2 года назад

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

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

  • @programming7844
    @programming7844 Год назад

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

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

  • @Satenc0
    @Satenc0 2 года назад

    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

  • @benjamine.ndugga729
    @benjamine.ndugga729 2 года назад

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

  • @I.amRisky
    @I.amRisky 2 года назад

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

  • @gokulaher2476
    @gokulaher2476 2 года назад +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

  • @luizgustavoghisi8725
    @luizgustavoghisi8725 3 года назад +1

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

  • @rahatkhemissi8733
    @rahatkhemissi8733 2 года назад

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

  • @chcamp
    @chcamp 2 года назад

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

  • @salmayassin671
    @salmayassin671 Год назад

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

  • @Scoty98
    @Scoty98 2 года назад +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!

  • @rodrickngonyoku5042
    @rodrickngonyoku5042 3 года назад

    Nice accent, nice tutorial

  • @12crenshaw
    @12crenshaw 5 месяцев назад

    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

  • @dennielluissadian5026
    @dennielluissadian5026 2 года назад

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

  • @andersonportoS
    @andersonportoS Год назад

    Lindo

  • @Kapalatus
    @Kapalatus 2 года назад

    My name is simon :) i like

  • @reiskoryphae
    @reiskoryphae 2 года назад

    Note for myself
    19:20

  • @SamirJzVFX
    @SamirJzVFX 2 года назад

    17:45

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

  • @user-gv7jq1lm4u
    @user-gv7jq1lm4u 2 года назад

    finally not indian!!!!!

  • @Justin-xy2ko
    @Justin-xy2ko Год назад

    why are you not Indian????

  • @JaiKumar-jh7hl
    @JaiKumar-jh7hl 3 месяца назад

    Bad

  • @SailBuddha
    @SailBuddha 2 года назад

    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'

  • @imamiatechsolutions
    @imamiatechsolutions 6 месяцев назад

  • @user-pj2ch4yw5g
    @user-pj2ch4yw5g 2 года назад

    awesome