JPA / Hibernate One to One Mapping Example with Spring Boot

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 KZread 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
    @ashishraroliya99323 жыл бұрын

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

  • @b1onic98
    @b1onic984 жыл бұрын

    Good job, keep it up and thank you

  • @yogeshchoudhar5469
    @yogeshchoudhar54692 жыл бұрын

    Sir, ekdam Bhari 🔥🔥

  • @prajwaldhanke6087
    @prajwaldhanke60873 жыл бұрын

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

  • @suvammohanty7105
    @suvammohanty71052 жыл бұрын

    No words for u just love it ❣❣❣

  • @harikrishna3538
    @harikrishna35384 жыл бұрын

    HI Ramesh your explanation is so nice.

  • @JavaGuides

    @JavaGuides

    4 жыл бұрын

    Thank you.

  • @javatechnology4481
    @javatechnology44814 жыл бұрын

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

  • @tkbhateja2071
    @tkbhateja20713 жыл бұрын

    Great Teaching ... :)

  • @LibbyAudrey
    @LibbyAudrey2 жыл бұрын

    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
    @sreenivasulu474 жыл бұрын

    Good Explanation...

  • @nis02002
    @nis020022 жыл бұрын

    great post!thankyou

  • @anitathimothy
    @anitathimothy2 жыл бұрын

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

  • @untipejoahi
    @untipejoahi3 жыл бұрын

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

  • @mikloscsuvar6097
    @mikloscsuvar6097 Жыл бұрын

    Excellent.

  • @sarthakthakur87
    @sarthakthakur873 жыл бұрын

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

  • @manojarya7676
    @manojarya7676 Жыл бұрын

    Awesome....😍👌👍🔥.

  • @hanumanhiwarkar3350
    @hanumanhiwarkar33503 жыл бұрын

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

  • @mdtanweeralam6871
    @mdtanweeralam68712 жыл бұрын

    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
    @eliasnicolas64432 жыл бұрын

    Thank you

  • @Pain-qu5nr
    @Pain-qu5nr Жыл бұрын

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

  • @umaparvathi606
    @umaparvathi6063 жыл бұрын

    This also nice sir

  • @abdelhamidtahiri9462
    @abdelhamidtahiri94623 жыл бұрын

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

  • @gyanasahu1006
    @gyanasahu10063 жыл бұрын

    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.

  • @JavaGuides
    @JavaGuides4 жыл бұрын

    JPA / Hibernate One to Many Mapping Example with Spring Boot at kzread.info/dash/bejne/dKmtw5SpnNrRmpc.html JPA / Hibernate Many to Many Mapping Example with Spring Boot at kzread.info/dash/bejne/X6Vt1NJroN3cd7g.html

  • @subramanianchenniappan4059
    @subramanianchenniappan40593 жыл бұрын

    thanks bro

  • @trademoneynothealth
    @trademoneynothealth4 жыл бұрын

    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
    @smileyakhi1654 жыл бұрын

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

  • @kotinkarwak
    @kotinkarwak3 жыл бұрын

    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
    @kvnagendra53542 жыл бұрын

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

  • @eliasnicolas6443

    @eliasnicolas6443

    2 жыл бұрын

    hibernate does it for you

  • @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
    @radhapandikunta38193 жыл бұрын

    Child table forgein key inserting as null

  • @jingli2168
    @jingli21684 жыл бұрын

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

  • @JavaGuides

    @JavaGuides

    4 жыл бұрын

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

  • @sarthakthakur87
    @sarthakthakur873 жыл бұрын

    NICEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE

  • @seemaprajapati964
    @seemaprajapati9644 жыл бұрын

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

  • @paulmimicry9147
    @paulmimicry91473 жыл бұрын

    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
    @nicholaswhite73513 жыл бұрын

    Happy birthday 3 days ago)

  • @JavaGuides

    @JavaGuides

    3 жыл бұрын

    Thank you!

  • @sharadrakeshmaddheshiya6955
    @sharadrakeshmaddheshiya69552 жыл бұрын

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

  • @sriram.r8018
    @sriram.r80182 жыл бұрын

    😃😃😃

  • @Ckvietvu
    @Ckvietvu Жыл бұрын

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

  • @user-uu9hx9it3b
    @user-uu9hx9it3b Жыл бұрын

    Indian English ;)

  • @thejas6922
    @thejas69229 күн бұрын

    Eat something bro..No energy

  • @JavaGuides

    @JavaGuides

    9 күн бұрын

    @@thejas6922 ok bro