I want to have two way relationship like Teacher contains reference of Student
and Student contains reference of Teacher. Is it even possible in iBatis ?
class Teacher {
Student sid;
....
}
class Student {
Teacher teacher;
....
}
I wrote the following SQL config file and as expected I got stack over flow due
to recursion.(Map referring each other)
<resultMap id="TeacherResultMap99" class="Teacher" groupBy="id" >
<result property="id" column="tea_id"/>
<result property="name" column="tea_name" />
<result property="sid" resultMap="JOB.StudentResultMap99"/>
</resultMap>
<resultMap id="StudentResultMap99" class="Student" >
<result property="id" column="stu_id"/>
<result property="name" column="stu_Name"/>
<result property="teacher" resultMap="JOB.TeacherResultMap99"/>
</resultMap>
<select id="findStudent" parameterClass="int" resultMap="StudentResultMap99">
select t.id as tea_id , t.name as tea_name , s.id as stu_id, s.name as
stu_Name , s.tid as stu_tid from Teacher t left join student s on t.id = s.tid
where s.id = #value#
</select>
Thanks,
Petr