Dear madam/sir,
I hava to classes in my project (Student and Couse) as follows,
public class Student {
int id ;
java.util.List courses ;
//setter and getter methods
}
public class Course {
int id;
String name ;
//setter and getter methods
}
and I used to hibernate mapping to map them to db as follows
=======================================================
<hibernate-mapping>
<class name="Student" table="STUDENT">
<id name="id" type="int" column="id">
<generator class="increment"/>
</id>
<bag name="courses" cascade="all" >
<key column="student_id"/>
<one-to-many class="Course"/>
</bag>
</class>
</hibernate-mapping>
=======================================================
<hibernate-mapping>
<class name="Course" table="COURSE">
<id name="id" type="int" column="id">
<generator class="increment"/>
</id>
<property name="name" column="NAME" type="string"/>
</class>
</hibernate-mapping>
==================================================================
when I save a Student object with it's associations, it and it's associations do not save properly, student_id column in COURSE table, has not any value, so in retrieving Student, it's courses do not load !!
but if I add a many-to-one element in course mapping file, everything woulde be ok then,
My PROBLEM is, I want to have unidirectional mapping, just from student to course, not reverse.
what can I do then, to solve?
regards
AliReza