#10. OneToOne Mapping | Hibernate Mapping | Hibernate Tutorial in hindi

Поделиться
HTML-код
  • Опубликовано: 28 янв 2025

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

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

    I watched some more videos related to mapping before this but in those half knowledge was provided and that's why I was confused. I searched some more and found this channel, you cleared my each and every doubt, thanks

  • @Codestry
    @Codestry 4 года назад +59

    Guys if your getting the below error:
    ERROR: Cannot add or update a child row: a foreign key constraint fails (`myhiber`.`question`, CONSTRAINT `FK3nwehyx3nxmikx8n7pmd6qyju` FOREIGN KEY (`answer_Answer_Id`) REFERENCES `answer` (`Answer_Id`))
    Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
    Then please check your main method() in the source file if after
    session.save(qstn);

    you have added this or not >>> session.save(ans);

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

      Thankyou bro. I was getting this error. Finally resolved

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

      Thank You .. I was also getting same error

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

      Thanks ASIM ....took one day to solve this error

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

      Thank you Asim for helping us😍

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

      Thanks bro , I was just about to quit for today but your comment saved me 👍👍 resolved

  • @SandeepSharma-yq5wu
    @SandeepSharma-yq5wu 4 года назад +4

    You hand writing is more elegant and more beautiful than computer fonts. Thank you so much for all these useful training videos. Thank you sir!

  • @ajaypt1947
    @ajaypt1947 Год назад +2

    one of best thing about his tutorials he doesnt skip when error occurs he resolves in video
    keep teaching up
    thanks

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

      Hi , why my forein key value not showing , its showas me null value in forein key

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

      ​​@@deepaliupadhayay492 does it show any error?
      u should check if u have mapped both classes in xml,
      u should check if u are saving both objects,
      u should try enabling cascading
      Hope it helps

  • @pravinpatil-sy9nq
    @pravinpatil-sy9nq 4 года назад +12

    muliple cursor ctrl +shift+r

  • @Devloper56
    @Devloper56 3 дня назад

    Nicely Explain!

  • @PT-Tl1
    @PT-Tl1 4 года назад +14

    Configuration cfg = new Configuration();
    cfg.configure("hibernate.cfg.xml");
    SessionFactory factory = cfg.buildSessionFactory();

    //Creation Question

    Question q1 = new Question();
    q1.setQuestionId(101);
    q1.setQuestion("What is Java ?");

    //Creating Answer

    Answer answer = new Answer();
    answer.setAnswerId(201);
    answer.setAnswer("Java is a programming language");
    q1.setAnswer(answer);


    //Creation Question

    Question q2 = new Question();
    q2.setQuestionId(102);
    q2.setQuestion("What is Python ?");

    //Creating Answer

    Answer answer1 = new Answer();
    answer1.setAnswerId(202);
    answer1.setAnswer("Python is a programming language");
    q2.setAnswer(answer1);


    //session

    Session session = factory.openSession();
    Transaction tx = session.beginTransaction();

    session.save(answer);
    session.save(answer1);
    session.save(q1);
    session.save(q2);

    tx.commit();
    session.close();
    factory.close();
    A small mistake in my code wasted a lot of time. May be my pasted code can help someone. Thanks for the awesome tutorial, Sir.

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

      Thanks man, appreciate it.

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

    I suggest ,When you make a video then use of DARK BACKGROUND , it will help us for Eye comfort. Nice explaination. Thank you

  • @dileepkumarjha9631
    @dileepkumarjha9631 4 года назад +3

    please make a series of spring MVC with hibernate

  • @ritiksingh8268
    @ritiksingh8268 6 месяцев назад +1

    Durgesh bhai videos ke section bna dia kro thoda easy hota hai padhne me

  • @AtulPatel-h4y
    @AtulPatel-h4y 4 месяца назад +1

    Bahi app jo bolata ho na wo Rhoda slow ma bolo aur aka ka kar ka samajaya bahi tab to grow kara ga channel 😮😮😮😮

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

    You deserve more recognition bro

  • @sonukumar-bq3gf
    @sonukumar-bq3gf 4 года назад +1

    Thanks sir
    Please make Spring framework for students.

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

    Can you please add code snippet also in the description. It would be of great help. Thanks!

  • @mohitdeo780
    @mohitdeo780 11 месяцев назад

    hold alt key and left click mouse on the positions where you want multiple cursors

  • @yashchandarana6708
    @yashchandarana6708 3 года назад +4

    Why are you so underrated man I just love your tutorials

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

    sir jab m answer ko alag save krta hu jaise s.save(a1); or uske baad question ko save krta hu s.save(q1); to sab kuch thik ho jata h per jab jaisa aapne kiya video me ki aapne question ko hi save kiya answer automatically save ho jayega new table bnke or foreign key add ho jayegi apne aap question vali table me to
    ERROR: Cannot add or update a child row: a foreign key constraint fails
    ye error dikha rha h

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

      Same Bro!!

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

      How did you solve the problem?

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

      @@kartikagrawal5399 bhai ab to dyan nhi h🤣🤣🤣
      Jindgi har 6 month me dusri technology me jati rhti h

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

      @@kartikagrawal5399 baki bhai aap youtube pe search krlo same problem ka solution mil jayega

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

      @@kartikagrawal5399
      Question question = new Question();
      question.setQuestionId(1);
      question.setQuestion("What is java");

      Answer answer = new Answer();
      answer.setAsnwerId(1);
      answer.setAsnwer("java is programming language");
      question.setAnswer(answer);
      session.save(answer);
      session.save(question);

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

    How can we save both(question and answer) objects data using single save method .

  • @vivekraikwar1602
    @vivekraikwar1602 4 года назад +3

    Could not determine type for: com.learn.project1.Answer, at table: Question, for columns: [org.hibernate.mapping.Column(ans)]

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

    Very simple and clear explanation.. thanks a lot.. 👍

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

    bhai..2 ghante se pareshan ho raha tha..Thanx for giving what exactly i was looking for...amazing

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

    Thank you for explaining in simple and clear

  • @contentsbydhirajkumarjaiswal
    @contentsbydhirajkumarjaiswal 4 года назад +6

    In case of Oracle 11g Xpress edition, the code won't work unless and until we save the Answer object first. I we still force to run the code then
    ERROR: ORA-02291: integrity constraint (SYSTEM.FKEVO3UWX0W7O23M45UIG5442TL) violated - parent key not found
    The above exception is thrown.
    But I guess, as you are using MySQL so your code works even if you don't save the answer object.

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

      Yes , we have to save answer object first to get rid from integrity constraint error. Thanks alot buddy .

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

      No i am using MySQL then also facing same exception unless untill i save answer first

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

      @@ayushjain7555 same problem in mysql 3 days ho gye bhai aaj jake confirm huya hibernate ka version bhi change krr ke dekh liya tha thanks bhaiyo aap bhi devloper ho 1 type ke

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

    thanks sir you are delivering such hard contents in easy manar great....

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

    Sir, jab hum bidiectional OneToOne mapping use karke fir mappedBy karte hai, to ye to simple unidirectional OneToOne mapping jaise hi treat karega na,
    so why we not use unidirectional only instead of this much stuff?

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

      @vaishalidhore9042 I was thinking the same

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

    Hi, I have some doubt in the project, I could use your help for the same: 021-06-07 12:25:41.783 ERROR 8960 --- [ restartedMain] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.MappingException: Could not determine type for: com.karkinos.webapp.Patient, at table: document, for columns: [org.hibernate.mapping.Column(patients)]

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

    If we will fetch the answer, will be get its answer also?

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

    JAI HIND JAI BHARAT

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

    Very easily explained. Too the point video. Thanks a lot :)

  • @ujalamaurya292
    @ujalamaurya292 4 года назад +3

    Sir, Question class... insert and update ki query run nahi hua...
    Plzz reply ...

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

      Kya dikkat ho rhi?

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

      Database me value show nhi hua shirf column name dikh rha hai..

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

      Ho gya solve.. 😇
      Thank you for reply.. 😇

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

      Ujala Maurya kaise solve kiya kuch to batao

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

      bro solution bata do, mere isme bhi insert query fire nhi ho rhi h sirf table ban raha h but no data entry

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

    Sir i was getting stuck in this video , but finally was able to rectify the mistake

  • @SandeepKumar-se2fd
    @SandeepKumar-se2fd 3 года назад +1

    Great explanation, greedy towards your knowledge. 😄😄

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

    multi-cursers shortcut: (alt+left_click).

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

    why question and answer not showing in database after program run successfully also. can u plz give me solution

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

    👌👌

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

    I want to run this project on eclipse but I am using Linux OS Ubuntu so where can I get Hibernate external jar files..

  • @manishkumar-gk3it
    @manishkumar-gk3it 2 года назад +1

    Sir ek hi dil hai kitne bar jitoge❤️❤️😋😍😍😍😍😃🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏 jai bholenath jai hanuman ji

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

    Great Explanation!

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

    bhai are you using pen tab for writing ? which one?

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

    : Cannot add or update a child row: a foreign key constraint fails (`new2`.`question`, CONSTRAINT `FKb2e5ogg3ayod6wv5u0obkfyx3` FOREIGN KEY (`answer_ans_id`) REFERENCES `answer` (`ans_id`)) this type of error is comming

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

      @govindjaiswal3480
      I am also getting same error....how did you solve ? Can you help!

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

      ​@@kartikagrawal5399you need to save answer objects also:
      session.save(answer1);
      session.save(answer2); like this

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

    please make a series on microservices

  • @ashwanikumar-bw5lx
    @ashwanikumar-bw5lx 4 года назад

    hi, Durgesh, please make video on Spring Batch if possible.

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

    why did you save both question and ans?
    if you save question then it should be save ans also

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

    HI Sir,
    What happen if we does not keep @OneToOne Annotation [ mapping ] in Answer entity .

  • @shivamshukla-jd9xg
    @shivamshukla-jd9xg 4 года назад

    Sir,Apka Explain Karne ka tarika Bahut Achha Hai.

  • @dheerajpoonia29
    @dheerajpoonia29 8 месяцев назад

    easy explanation 👌

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

    Love From Pakistan

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

    constraint violation showing..commit() not excecuting?what to do?

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

    very nice Sir
    Keep posting Sir

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

    I have buy Soure Code of Hibernate.....but i didn't see any link to download.....plz reply

  • @pawansingh-xo1iz
    @pawansingh-xo1iz 2 года назад

    @LearnCodeWithDurgesh For multiple cursor --> ctrl+2 and then select Rename in file....

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

    By annotation its working fine but when I am trying with xml I am getting "Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because "index" is null" can anyone help on this. I am very new to hibernate.

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

      use load method instead

  • @BikashRout-u8j
    @BikashRout-u8j Год назад

    ctrl +alt (multi cursor)

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

    Awesome ❤

  • @_sarthak_.2
    @_sarthak_.2 2 года назад

    In Eclipse multi cursor Ctrl-Alt-J

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

    Its giving exception like key already present while running same program again again for that we need to change question Id every time ?

  • @manishkumar-gk3it
    @manishkumar-gk3it 2 года назад

    Sir you are genius in many ways proud to be your chela 😋😋😍😍

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

    Thank you so much for such a clean and clear explanation!!

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

    nyc explanation

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

    Excellent tutorial on hibernate OneToOne Mapping

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

    Exception in thread "main" java.lang.StackOverflowError
    Gettng this error while using System.out.println(question1); in biDirectional mapping
    Why this is happening

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

      whenevr i am printing an object i am getting this exception

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

    why use super constructor ? video timing(17.17)

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

    Nice tutorial,i am fresher, new in this series,bt understand all points

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

    Sir answer wali table ma data nahi insert horahi he but queation wali table ma data insert horahi he iska soliution samaj nahi araraha he 2 3 ber try kiya laken answer same araha he..
    Please sir solve this..

  • @Akash-di5tb
    @Akash-di5tb 2 года назад

    alt+leftClick for multiple cursor

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

    Please upload spring mvc with hibernate video

  • @Vinaykumar-bx1ql
    @Vinaykumar-bx1ql Год назад

    thank you so much sir.............

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

    Multi cursor k liye alt+left click

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

    Hi Sir, I'm getting this Error :
    ERROR: Cannot add or update a child row: a foreign key constraint fails (`hibernatelearning`.`question`, CONSTRAINT `FKbpp3dv1cwmcyfbuvmay7uypg` FOREIGN KEY (`answer_answerID`) REFERENCES `answer` (`answerID`))
    Please help to resolve, I'm not getting proper solutions for this

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

    Very good content than others on RUclips

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

    your channel is doing great

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

    Foriegn key not supported in MyISAM engine error aa rha h. Sir plz help

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

    sir error aa rhi h
    error executing DDL alter table question drop foreign key

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

    Wanted to understand the advantage of making entities bidirectional ?
    After making beans bidirectional when I am trying to get the object to Answer question values are not getting populated.

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

    Ctrl+Shift +/

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

    Best lecture...

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

    sir foreign key ko auto kr rhe h to chal raha h par manually m error de rha h

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

    sir mere me table to create ho raha hai workbench me but data nhi aa raha hai. null data

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

      Tum check karo ki session object ka save method sahi se call kia hain ki nahi. Ya fir transaction object ko commit kia hain ki nahi.

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

      same problem, insert query fire nhi ho rhi h....tables ban rhe h data entry nhi ho rhi h lekin, any solution?

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

    thankyou verymuch bro....

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

    ThanQ sir 🙏

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

    @Jointable vs @Joincolumn can anyone plz explain

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

    sir one to one ma mari alag table create ni hori

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

    Thanks sir

  • @SandeepKumar-so2st
    @SandeepKumar-so2st 4 года назад

    Great sir

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

    Thank Your Sir...

  • @ROHITSINGH-zz6xy
    @ROHITSINGH-zz6xy 4 года назад

    ERROR: Cannot add or update a child row: a foreign key constraint fails (`test`.`question`, CONSTRAINT `FKskqdlh4nc1ij4s806d6bjk5f1` FOREIGN KEY (`answer_answerId`) REFERENCES `answer` (`answerId`))
    Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement

  • @SOHELRANA-no6ur
    @SOHELRANA-no6ur 2 года назад

    OnetoMany and manytoOne run nahi ho raha !

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

    watch it in 1.5x save time :)

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

      4x with firefox extension :)

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

    ERROR: Cannot add or update a child row: a foreign key constraint fails (`newdb`.`question`, CONSTRAINT `FKs6ghcwuovtcp489oo5dy7rvk5` FOREIGN KEY (`answer_answer_id`) REFERENCES `answer` (`answer_id`))

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

      why this come?

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

      got the solution for this one??

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

      You have to save both question and answer objects in session i.e session.save(question); session.save(answer). Hope this will help :)

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

      @@dotexe6803 THANKS... IT'S WORKING

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

      @@kirtijain6675 Happy to help!

  • @syedfaizan5841
    @syedfaizan5841 10 месяцев назад

    thanks

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

    dunia bhar ki ad dal rkhi h yar

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

    Error: parent key not found

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

      In case of Oracle 11g Xpress edition, the code won't work unless and until we save the Answer object first. I we still force to run the code then
      ERROR: ORA-02291: integrity constraint (SYSTEM.FKEVO3UWX0W7O23M45UIG5442TL) violated - parent key not found
      The above exception is thrown.
      But I guess, as you are using MySQL so your code works even if you don't save the answer object.

  • @ShivamKumar-se1fo
    @ShivamKumar-se1fo 11 месяцев назад

    list

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

    Where is code ?

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

    tnks deer fur vdoeo

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

    Xclnt Xplanation

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

    why code download is paid ?

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

      🤑💰🤑💰🤑💰🤑💰

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

    what is the difference between Embedded and oneToOne?

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

    SQL Error: 1452, SQLState: 23000
    ERROR: Cannot add or update a child row: a foreign key constraint fails
    Anyone else getting this error?......plz help

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

      did u solve ? i got the same error

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

      please check your main method() in the source file if after
      session.save(qstn);

      you have added this ----> session.save(ans);

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

    Sir Sach me app padhate km ho bhagte zyada ho