File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes hibernate one-many example issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "hibernate one-many example issue" Watch "hibernate one-many example issue" New topic
Author

hibernate one-many example issue

Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
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

Joined: Jun 08, 2009
Posts: 238
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

Joined: Jul 09, 2008
Posts: 50
It seems to be as if the you already have some records in Student table.


Ram Parashar
http://doinfinite.com
Mathew Lee
Ranch Hand

Joined: Jun 08, 2009
Posts: 238
Hi Ram,

I forgot to make phone_id column within student_phone table as primary key. After changing that everything working fine. Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: hibernate one-many example issue