ibatis xml特别的用法

来源:互联网 发布:淘宝店铺买卖 安全吗 编辑:程序博客网 时间:2024/04/30 04:35

1)xml中使用In

Long[] cdcids;

params.put("cdcid", cdcids);

<selectid="queryWare"resultClass="Ware"parameterClass="Map">

        select

           storeid as storeId,

           wid,

           fdcid as fdcId

        from ware

        where  1=1

           <isNotNull prepend="and" property="cdcid">

                 fdcid in

                 <iterate  open="("  close=")"  conjunction="," property="cdcid">

                 #cdcid[]#

               </iterate>   

            </isNotNull>

        orderby fdcid

        <isNotNull property="startRow">

           limit $startRow$,$pageSize$

        </isNotNull>

    </select>

2)

<deleteid="deleteWareStockSetting"parameterClass="Map">

         deletefrom ware_stock_setting where fdcid in($fdcId$)

     </delete>

fdcId map中的KEY  valueString,”,”间隔


3) xml中日期格式转化,比较大小

<selectid="getBannedWareList" resultClass="BannedWare">

        selectbw.id,bw.wid, bw.wname,bw.src_id as srcId,

               bw.src_name as srcName,bw.tgt_id as tgtId

        from  banned_ware bw

        where date_format(now(),'%Y-%m-%d')<![CDATA[>=]]> date_format(effective_date,'%Y-%m-%d')

        and   date_format(now(),'%Y-%m-%d') <![CDATA[<=]]> date_format(release_date,'%Y-%m-%d')

    </select>   

4)

            <isEqual  property="sortType" compareValue="0">

                     orderby convert(w.wnameusing gbk) asc

            </isEqual>

            <isEqual  property="sortType" compareValue="1">

                     orderby item.fdcStock/(item.forecasting/7) asc

           </isEqual>

5)

<sqlid="Base_Column_List">

          id,product_code, product_name, wpid1, wpid1_name, wpid2, wpid2_name, wpid3,wpid3_name, purc_user_code, purc_user_name, vendor_code, vendor_name,create_date       

      </sql>

 

      <!--查詢商品信息表所有sku -->

      <selectid="queryProductListBySku"resultMap="product.BaseResultMap"parameterClass="java.util.List">

           SELECTDISTINCT

                 <include refid="Base_Column_List"/>

           FROM

                 product_info

           WHERE

                 product_code

           IN

                 <iterateclose=")"open="(" conjunction=","> 

                  <![CDATA[ 

                       #[]#  

                  ]]>  

                 </iterate>

      </select>

6)

<selectid="queryStablityFactor"parameterClass="java.util.Map"resultClass="StabilityFactor">

     SELECT fdcid,wpid2,(SUM(stability_factor)/#weeks#) stabilityFactor 

FROM stability_factor WHERE create_time BETWEEN(CURDATE() - INTERVAL 22 DAY) AND (CURDATE() + INTERVAL 1 DAY)

         <isNotEmptyproperty="wpid2">

               and wpid2 = #wpid2#

         </isNotEmpty>

         <isNotEmptyproperty="fdcid">

              and fdcid=#fdcid

         </isNotEmpty>

     GROUP BY fdcid, wpid2

     </select>

7)

<insertid="insertFilterRateAndWrongRate"parameterClass="Map">

         insertinto filter_rate_and_wrong_rate

         (fdcid,filter_rate,wrong_rate,WEEK,creator,create_time,total,year,orgid)

         values(#fdcid#,#filter_rate#,#wrong_rate#, WEEKOFYEAR(CURDATE()),0,now(),#total#,YEAR(CURDATE()),#orgid#)

     </insert>

8)

<deleteid="deleteWareStockSetting"parameterClass="Map">

         deletefrom ware_stock_setting where fdcid in($fdcId$)

     </delete>

fdcIdmap中的KEY  valueString,”,”间隔



0 0
原创粉丝点击