IBatis multi-Table query, iBatis

Source: Internet
Author: User

IBatis multi-Table query, 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 multi-Table query

I am also studying. I am developed in java, but the principle is the same. Let me talk about what I did!
Write A private List <Grade> grades; field in Table A in the Entity class.
Then modify the file xxxx. namingsql. xml.
<Result property = "grades" column = "id" select = "getGradeByUserId"/>

"GetGradeByUserId" is the ID of the query statement to be written to query all the two-dimensional tables.
<Select id = "getGradeByUserId" parameterClass = "int" resultClass = "orders table">
<! [CDATA [
Select student ID, course name, course score from B where student ID = # value #
]>
</Select>

This queries all the information in.
<Select id = "getUserList" resultMap = "result">
Select student ID, Student name, and gender from
</Select>
When you write a method and call getUserList, The getGradeByUserId method is automatically called to populate data in B with grades.

IBATIS multi-Table query

ResultMap = "java. util. HashMap"

Write SQL as follows:
Select sum (odd_price) sumoddprice, odr_customer_id custid
From sal_order join orders_line
On odd_order_id = odr_id
Group by odd_order_id

Then use hashMap. Get *** Value

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.