This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

hibernate one-many example issue  RSS feed

 
Mathew Lee
Ranch Hand
Posts: 238
  • 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
  • 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
  • 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
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!