On page 27 of iBatis SQL Mapper Doc the following mapping xml file is given:

<resultMap id=”get-category-result”
class=”com.ibatis.example.Category”>
<result property=”id” column=”CAT_ID”/>
<result property=”description” column=”CAT_DESCRIPTION”/>
<result property=”productList” column=”CAT_ID” select=”
getProductsByCatId”/>
</resultMap>
<resultMap id=”get-product-result”
class=”com.ibatis.example.Product”>
<result property=”id” column=”PRD_ID”/>
<result property=”description” column=”PRD_DESCRIPTION”/>
</resultMap>
<statement id=”getCategory” parameterClass=”int”
resultMap=”get-category-result”>
select * from CATEGORY where CAT_ID = #value#
</statement>
<statement id=”getProductsByCatId” parameterClass=”int”
resultMap=”get-product-result”>
select * from PRODUCT where PRD_CAT_ID = #value#
</statement>

For the corresponding object model, the Category class should have
productList property, OK. What about Product class? Can it have a
reference to Category?

Thanks.

--
Ersin

Reply via email to