Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in one-to-many mapping

 
indu iyengar
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

am trying to store an object by using one-to-many relationship ...
it shows the exception as

basic relationship is ::
one student can join in multiple courses...

code for course

code for student


mapping file

please let me know what is wrong with my code ?
 
joy b chakravarty
Ranch Hand
Posts: 62
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
private List<String> courses;


shouldn't this be
 
Waswani Naresh
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Indu,

As Joy mentioned , change the List<String> to List<Course> and it will solve your problem.

Regards,
Naresh
 
indu iyengar
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for your replies.. I just changed as you said..

now , its not showing any exception..coming to success page without storing .

here am posting my hbm file and code to store the object..



 
indu iyengar
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help me friends.. didn't resolved yet..

I don't know exactly how to write the .hbm file for relationships..

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic