• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate one-many example issue

 
Mathew Lee
Ranch Hand
Posts: 238
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying hibernate one-many mapping example on mysql database server from link
http://www.vaannila.com/hibernate/hibernate-example/hibernate-mapping-one-to-many-1.html

when i execute the main.java class getting following error.





Please advise on how to resolve it. Any ideas, suggestions, resources, sample code highly appreciated. Thanks in advance.
 
Mathew Lee
Ranch Hand
Posts: 238
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I made phone_id column as auto-increment in phone table and again executed main.java. this time the error message changed to



Please advise
 
Ram Para
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems to be as if the you already have some records in Student table.
 
Mathew Lee
Ranch Hand
Posts: 238
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ram,

I forgot to make phone_id column within student_phone table as primary key. After changing that everything working fine. Thank you.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic