JPA / Hibernate One to One Mapping Example with Spring Boot

Поділитися
Вставка
  • Опубліковано 3 чер 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 UA-cam 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

КОМЕНТАРІ • 56

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

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

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

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

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

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

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

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

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

  • @Pain-qu5nr
    @Pain-qu5nr Рік тому

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

  • @harikrishna3538
    @harikrishna3538 4 роки тому

    HI Ramesh your explanation is so nice.

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

    Sir, ekdam Bhari 🔥🔥

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

    No words for u just love it ❣❣❣

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

    Good job, keep it up and thank you

  • @javatechnology4481
    @javatechnology4481 4 роки тому +1

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

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

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

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

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

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

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

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

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

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

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

  • @sreenivasulu47
    @sreenivasulu47 4 роки тому

    Good Explanation...

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

    Wonderful. Good Job

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

    Great Teaching ... :)

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

    great post!thankyou

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

    Thank you

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

    Excellent.

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

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

    Awesome....😍👌👍🔥.

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

    This also nice 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 2 роки тому

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

  • @smileyakhi165
    @smileyakhi165 4 роки тому

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

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

    thanks bro

  • @kvnagendra5354
    @kvnagendra5354 2 роки тому +2

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

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

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

    Child table forgein key inserting as null

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

  • @JavaGuides
    @JavaGuides  4 роки тому

    JPA / Hibernate One to Many Mapping Example with Spring Boot at ua-cam.com/video/Buya2plwkj4/v-deo.html
    JPA / Hibernate Many to Many Mapping Example with Spring Boot at ua-cam.com/video/-q9rp2pzvGU/v-deo.html

  • @sharadrakeshmaddheshiya6955

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

  • @sriram.r8018
    @sriram.r8018 2 роки тому

    😃😃😃

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

    Happy birthday 3 days ago)

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

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

  • @user-uu9hx9it3b
    @user-uu9hx9it3b Рік тому

    Indian English ;)

  • @Kasunvidmalgmailcom
    @Kasunvidmalgmailcom 3 місяці тому

    I have a question, if there is one to one relationship is happen, why it display one to many relationship. if there is one to one relationship happen it need to show like