首頁 >資料庫 >mysql教程 >iBatis多表查询

iBatis多表查询

WBOY
WBOY原創
2016-06-07 16:01:181180瀏覽

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=prona

<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>

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn