這也是 ibatis 好上手的原因,簡單說它的寫法都很直覺。以下看個 1:1 的例子
<resultMap id="getStudentResult" class=”com.ibatis.example.Product”>
<result property="student_id" column="STD_ID"/>
<result property="student_name" column="STD_NAME"/>
<result property="room" column="STD_ROOM_ID" select="getRoom"/>
</resultMap>
<resultMap id="getRoomResult" class=”com.ibatis.example.Category”>
<result property="room_id" column="ROOM_ID"/>
<result property="room_name" column="ROOM_NAME"/>
</resultMap>
<statement id="getStudent" parameterClass="int" resultMap="getStudentResult">
select * from STUDENT where STD_ID = #value#
</statement>
<statement id="getRoom" parameterClass="int" resultMap="getRoomResult">
select * from ROOM where ROOM_ID = #value#
</statement>