File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes problem in one-to-many mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "problem in one-to-many mapping" Watch "problem in one-to-many mapping" New topic

problem in one-to-many mapping

indu iyengar
Ranch Hand

Joined: Jul 30, 2010
Posts: 115
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 ?

thanks ,
joy b chakravarty
Ranch Hand

Joined: May 16, 2011
Posts: 62

private List<String> courses;

shouldn't this be

Cheers, Joy [SCJP 1.4, SCBCD 5.0]
get high on alcohol, algorithm or both
Waswani Naresh
Ranch Hand

Joined: May 01, 2008
Posts: 66
Hi Indu,

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


Naresh Waswani
indu iyengar
Ranch Hand

Joined: Jul 30, 2010
Posts: 115
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

Joined: Jul 30, 2010
Posts: 115
Please help me friends.. didn't resolved yet..

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

I agree. Here's the link:
subject: problem in one-to-many mapping
jQuery in Action, 3rd edition