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
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);
@@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
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.
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
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.
@@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
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?
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)]
: 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
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.
Exception in thread "main" java.lang.StackOverflowError Gettng this error while using System.out.println(question1); in biDirectional mapping Why this is happening
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..
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
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.
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.
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
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);
Thankyou bro. I was getting this error. Finally resolved
Thank You .. I was also getting same error
Thanks ASIM ....took one day to solve this error
Thank you Asim for helping us😍
Thanks bro , I was just about to quit for today but your comment saved me 👍👍 resolved
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!
one of best thing about his tutorials he doesnt skip when error occurs he resolves in video
keep teaching up
thanks
Hi , why my forein key value not showing , its showas me null value in forein key
@@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
muliple cursor ctrl +shift+r
Thanks
Nicely Explain!
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.
Thanks man, appreciate it.
I suggest ,When you make a video then use of DARK BACKGROUND , it will help us for Eye comfort. Nice explaination. Thank you
please make a series of spring MVC with hibernate
Durgesh bhai videos ke section bna dia kro thoda easy hota hai padhne me
Bahi app jo bolata ho na wo Rhoda slow ma bolo aur aka ka kar ka samajaya bahi tab to grow kara ga channel 😮😮😮😮
You deserve more recognition bro
Thanks sir
Please make Spring framework for students.
Can you please add code snippet also in the description. It would be of great help. Thanks!
hold alt key and left click mouse on the positions where you want multiple cursors
Why are you so underrated man I just love your tutorials
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
Same Bro!!
How did you solve the problem?
@@kartikagrawal5399 bhai ab to dyan nhi h🤣🤣🤣
Jindgi har 6 month me dusri technology me jati rhti h
@@kartikagrawal5399 baki bhai aap youtube pe search krlo same problem ka solution mil jayega
@@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);
How can we save both(question and answer) objects data using single save method .
Could not determine type for: com.learn.project1.Answer, at table: Question, for columns: [org.hibernate.mapping.Column(ans)]
Very simple and clear explanation.. thanks a lot.. 👍
bhai..2 ghante se pareshan ho raha tha..Thanx for giving what exactly i was looking for...amazing
Thank you for explaining in simple and clear
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.
Yes , we have to save answer object first to get rid from integrity constraint error. Thanks alot buddy .
No i am using MySQL then also facing same exception unless untill i save answer first
@@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
thanks sir you are delivering such hard contents in easy manar great....
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?
@vaishalidhore9042 I was thinking the same
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)]
If we will fetch the answer, will be get its answer also?
JAI HIND JAI BHARAT
Very easily explained. Too the point video. Thanks a lot :)
Sir, Question class... insert and update ki query run nahi hua...
Plzz reply ...
Kya dikkat ho rhi?
Database me value show nhi hua shirf column name dikh rha hai..
Ho gya solve.. 😇
Thank you for reply.. 😇
Ujala Maurya kaise solve kiya kuch to batao
bro solution bata do, mere isme bhi insert query fire nhi ho rhi h sirf table ban raha h but no data entry
Sir i was getting stuck in this video , but finally was able to rectify the mistake
Great explanation, greedy towards your knowledge. 😄😄
multi-cursers shortcut: (alt+left_click).
why question and answer not showing in database after program run successfully also. can u plz give me solution
👌👌
I want to run this project on eclipse but I am using Linux OS Ubuntu so where can I get Hibernate external jar files..
Sir ek hi dil hai kitne bar jitoge❤️❤️😋😍😍😍😍😃🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏🙏 jai bholenath jai hanuman ji
Great Explanation!
bhai are you using pen tab for writing ? which one?
: 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
@govindjaiswal3480
I am also getting same error....how did you solve ? Can you help!
@@kartikagrawal5399you need to save answer objects also:
session.save(answer1);
session.save(answer2); like this
please make a series on microservices
hi, Durgesh, please make video on Spring Batch if possible.
why did you save both question and ans?
if you save question then it should be save ans also
Yes if u are using cascade
HI Sir,
What happen if we does not keep @OneToOne Annotation [ mapping ] in Answer entity .
It won't generate foreign key.
Nothing will happen. Just your mapping will be unidirectional.
Sir,Apka Explain Karne ka tarika Bahut Achha Hai.
easy explanation 👌
Love From Pakistan
constraint violation showing..commit() not excecuting?what to do?
very nice Sir
Keep posting Sir
I have buy Soure Code of Hibernate.....but i didn't see any link to download.....plz reply
@LearnCodeWithDurgesh For multiple cursor --> ctrl+2 and then select Rename in file....
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.
use load method instead
ctrl +alt (multi cursor)
Awesome ❤
In Eclipse multi cursor Ctrl-Alt-J
Its giving exception like key already present while running same program again again for that we need to change question Id every time ?
Yes
Or just change the hbm2ddl property to create then it will work fine
Sir you are genius in many ways proud to be your chela 😋😋😍😍
Thank you so much for such a clean and clear explanation!!
nyc explanation
Excellent tutorial on hibernate OneToOne Mapping
Exception in thread "main" java.lang.StackOverflowError
Gettng this error while using System.out.println(question1); in biDirectional mapping
Why this is happening
whenevr i am printing an object i am getting this exception
why use super constructor ? video timing(17.17)
Nice tutorial,i am fresher, new in this series,bt understand all points
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..
Hibernating cascading wali video dekho
Thank you sir its solved...
alt+leftClick for multiple cursor
Please upload spring mvc with hibernate video
i agree with you
thank you so much sir.............
Multi cursor k liye alt+left click
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
save answer object first then question object
@@priyodas755 not working
@@priyodas755 thanks buddy
@@nitishnegi2449 Thanks it works now
Very good content than others on RUclips
your channel is doing great
Foriegn key not supported in MyISAM engine error aa rha h. Sir plz help
Use correct dialect in config file
org.hibernate.dialect.MySQL5Dialect
Dialect use kiya hu sir
Mysql ka koun sa version use kar rhe ho?
Agar 5.7 mysql version hai to
org.hibernate.dielect.MySQL57Dielect use karo...
Apne db ke accordingly
@@LearnCodeWithDurgesh 8.0.13
sir error aa rhi h
error executing DDL alter table question drop foreign key
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.
Ctrl+Shift +/
Best lecture...
sir foreign key ko auto kr rhe h to chal raha h par manually m error de rha h
sir mere me table to create ho raha hai workbench me but data nhi aa raha hai. null data
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.
same problem, insert query fire nhi ho rhi h....tables ban rhe h data entry nhi ho rhi h lekin, any solution?
thankyou verymuch bro....
ThanQ sir 🙏
@Jointable vs @Joincolumn can anyone plz explain
sir one to one ma mari alag table create ni hori
Thanks sir
Great sir
Thank Your Sir...
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
Please Help It is throwing an exception
SOLTION KYA HAI ISKA ?
OnetoMany and manytoOne run nahi ho raha !
watch it in 1.5x save time :)
4x with firefox extension :)
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`))
why this come?
got the solution for this one??
You have to save both question and answer objects in session i.e session.save(question); session.save(answer). Hope this will help :)
@@dotexe6803 THANKS... IT'S WORKING
@@kirtijain6675 Happy to help!
thanks
dunia bhar ki ad dal rkhi h yar
Error: parent key not found
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.
list
Where is code ?
tnks deer fur vdoeo
Xclnt Xplanation
why code download is paid ?
🤑💰🤑💰🤑💰🤑💰
what is the difference between Embedded and oneToOne?
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
did u solve ? i got the same error
please check your main method() in the source file if after
session.save(qstn);
you have added this ----> session.save(ans);
Sir Sach me app padhate km ho bhagte zyada ho