Home >Database >Mysql Tutorial >iBatis多表查询

iBatis多表查询

WBOY
WBOYOriginal
2016-06-07 16:01:181182browse

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>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn