JPA / Hibernate One to One Mapping Example with Spring Boot

Поделиться
HTML-код
  • Опубликовано: 27 июл 2024
  • In this video tutorial, You’ll learn how to define a one-to-one relationship between two entities using JPA and Hibernate.
    Source code on my GitHub repository at github.com/RameshMF/spring-bo....
    Hibernate maps the tables in your database to the Entity classes in your application.
    You can define relationships among these entities in the same way you define relationships among the tables in your database.
    Let’s consider an application that stores a lot of information about its users so that it can provide a personalized experience to them.
    In such cases, it makes sense to store users primary details like name, email, password in a USERS table and store all the other secondary details in a separate table called USER_PROFILES, and have a one-to-one relationship between USERS and USER_PROFILES table.
    JPA / Hibernate One to Many Mapping Example with Spring Boot at • JPA / Hibernate One to...
    JPA / Hibernate Many to Many Mapping Example with Spring Boot at • JPA / Hibernate Many t...
    #javaguides #hibernate #springboot
    Java Guides Website: www.javaguides.net/
    About me: www.javaguides.net/p/about-me...
    Subscribe to our RUclips channel at / javaguides
    Java 8 Tutorials - • Java 8 Tutorials
    Spring Boot Tutorials - • Spring Boot Tutorial
    Java Tutorials - • Java Tutorials
    Java Best Practices - • Java Best Practices
    Design Patterns in Java - • Design Patterns in Java
    Servlet JSP Tutorials - • Servlet JSP Tutorials
    Spring MVC Tutorials - • Spring MVC Tutorial
    Hibernate 5 Tutorials - • Hibernate 5 Tutorial
    MongoDB Tutorials - • MongoDB Tutorial

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

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

    Such nice explanation,l really like it.your speaking like to the point and no other extra stuff like other youtubers, really explained very well👍

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

    bahut mast tuts h bhai aapke.... bahut help milti h apke codes se

  • @b1onic98
    @b1onic98 4 года назад

    Good job, keep it up and thank you

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

    Sir, ekdam Bhari 🔥🔥

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

    hi ramesh.... your videos are very usefull for me.

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

    No words for u just love it ❣❣❣

  • @harikrishna3538
    @harikrishna3538 4 года назад

    HI Ramesh your explanation is so nice.

  • @javatechnology4481
    @javatechnology4481 4 года назад +1

    Very useful. We want video tutorials on many to many and one to many mappings. 👍

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

    Great Teaching ... :)

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

    This is great! If I want to pull a column different from the first column/ip_id from the UserProfiles table, how would I do that?

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

    Wonderful. Good Job

  • @sreenivasulu47
    @sreenivasulu47 4 года назад

    Good Explanation...

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

    great post!thankyou

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

    Can you please demonstrate crud operation if there are two tables with referential integrity constraints

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

    No words, man. I really like your videos: Explicit, simple and clean-codding. Keep it up!

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

    Excellent.

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

    Sir make a video on Spring REST with hibernate mappings.
    That will be great

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

    Awesome....😍👌👍🔥.

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

    Very nice and simple explanation love your teaching. BTW the keyboard sounds amazing

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

    Both the table that is user and user profile has same column name "id" as primary key, is there any relationship between these two same column name "id".

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

    Thank you

  • @Pain-qu5nr
    @Pain-qu5nr Год назад

    Can I get all the details from both tables? Using the findByID method in UserRepository???

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

    This also nice sir

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

    Please stick to table structure shown @1:30. According to that in Users class it should be @JoinColumn(name = "user_profile_up_id", referencedColumnName = "up_id"). It looked confusing while explaining.

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

    you can do un video about how using inhereated class with JPA ..

  • @JavaGuides
    @JavaGuides  4 года назад

    JPA / Hibernate One to Many Mapping Example with Spring Boot at ruclips.net/video/Buya2plwkj4/видео.html
    JPA / Hibernate Many to Many Mapping Example with Spring Boot at ruclips.net/video/-q9rp2pzvGU/видео.html

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

    thanks bro

  • @trademoneynothealth
    @trademoneynothealth 4 года назад +4

    I have a doubt its working for me this way but if i try to have userid as foreign key in userprofile table its getting inserted as null i have changed all the annotations as well

  • @smileyakhi165
    @smileyakhi165 4 года назад

    Sir please provide the source code link. Am almost done but there is small mistake for me. Link plz sir

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

    Anyone please explain to me the need for the statement run in setting up the user.
    He created the instances for use and then for profile. Set the user.setprofile... and profile.setuser. why is the profile.setuser part needed in cascade is set to all and we only calling .save on the user repository? Am confusing my little brains here so would appreciate any explainers. Thanks for the vids

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

      First you check the table relationship on er model it has bidirectional

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

    19:58 sir sir u saved user only with userRepository but what about userprofile obj how does it saved

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

    how to add data dynamically and access them through postman in one to one mapping ,pls make a video on this, btw nice tutorial

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

    Child table forgein key inserting as null

  • @jingli2168
    @jingli2168 4 года назад

    why u need to add userProfileRepository injected in main???

    • @JavaGuides
      @JavaGuides  4 года назад +1

      That is not required. If you want check bidirectional one to one mapping then you can use it

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

    NICEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

  • @seemaprajapati964
    @seemaprajapati964 4 года назад +1

    Ramesh pls put some energy in yourself while teaching otherwise u r awesome man

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

    How to fetch?? Inserting is easy but how about fetch?

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

      Use findById(), findAll() methods to fetch the data. Inserting is quite tricky in association but fetching is very easy.

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

    Happy birthday 3 days ago)

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

    Every thing Is Super Perfect👌 ...but why do u keep using "birthOfDate"...it's "dateOfBirth".😉

  • @sriram.r8018
    @sriram.r8018 2 года назад

    😃😃😃

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

    Good explanation but ur English is quite difficult for me to understand. Tks

  • @user-uu9hx9it3b
    @user-uu9hx9it3b Год назад

    Indian English ;)

  • @thejas6922
    @thejas6922 9 дней назад

    Eat something bro..No energy