首页 > 代码库 > iBatis多表查询

iBatis多表查询

<typeAlias alias="Product" type="com.shopping.entity.Product"/>     
    <typeAlias alias="ProductType" type="com.shopping.entity.ProductType"/>      
    
    <resultMap id="queryAllProduct" class="Product">     
     <result property="proId" column="proid"/>
     <result property="proName" column="proname"/>
     <result property="proDesc" column="prodesc"/>
     <result property="price" column="price"/>
     <result property="img" column="img"/>
     <result property="proTime" column="protime"/>
     <result property="size" column="size"/>
     <result property="type" column="typeid" select="queryProductTypeById"/>     
    </resultMap>  

<select id="queryProductTypeById" parameterClass="int" resultClass="ProductType" >
  select typeid,typename from producttype where typeid=#typeid#
<select>

<select id="queryAllProducts" resultMap="queryAllProduct">
  select proid,proname,prodesc,price,img,protime,size,typeid from product
<select>

iBatis多表查询