ibatis.net 中SqlMaps的xml文件的例子

  1 <?xml version="1.0" encoding="utf-8" ?>
  2 <!--============================================================================
  3 //    CAUTION: This file is generated by lwq.IBatisNetGen.BatisMap.cst at 2015/9/9 16:10:25
  4 //                Any manual editing will be lost in re-generation.
  5 //===========================================================================
  6 //Name:SysAdminMap.xml
  7 //Author: liuweiqin
  8 //Description: 
  9 //datatime:2015/9/12 12:10:28-->
 10 <sqlMap namespace="SysAdmin"
 11     xmlns="http://ibatis.apache.org/mapping"
 12     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 13 
 14   <alias>
 15     <typeAlias alias="SysAdmin" type="YY.MicroNet.Model.SysAdmin,YY.MicroNet.Model"/>
 16   </alias>
 17 
 18   <resultMaps>
 19     <resultMap id="FullResultMap" class="SysAdmin">
 20       <result property="PKAdmin" column="PK_Admin" dbType="VarChar"/>
 21       <result property="PsnCode" column="PsnCode" dbType="VarChar"/>
 22       <result property="PsnName" column="PsnName" dbType="NVarChar"/>
 23       <result property="CorpCode" column="CorpCode" dbType="VarChar"/>
 24       <result property="CorpName" column="CorpName" dbType="NVarChar"/>
 25       <result property="DeptCode" column="DeptCode" dbType="VarChar"/>
 26       <result property="DeptName" column="DeptName" dbType="NVarChar"/>
 27       <result property="Email" column="Email" dbType="VarChar"/>
 28       <result property="DomainAccount" column="DomainAccount" dbType="NVarChar"/>
 29       <result property="OperaterCode" column="OperaterCode" dbType="VarChar"/>
 30       <result property="OperaterName" column="OperaterName" dbType="NVarChar"/>
 31       <result property="DEF01" column="DEF01" dbType="NVarChar"/>
 32       <result property="DEF02" column="DEF02" dbType="NVarChar"/>
 33       <result property="DEF03" column="DEF03" dbType="Int"/>
 34       <result property="DEF04" column="DEF04" dbType="Int"/>
 35       <result property="DEF05" column="DEF05" dbType="Bit"/>
 36       <result property="Dr" column="Dr" dbType="Bit"/>
 37       <result property="Ts" column="Ts" dbType="DateTime"/>
 38     </resultMap>
 39   </resultMaps>
 40   <parameterMaps>
 41     <!--这里写存储过程的参数。parameterMap中的参数个数和顺序要和存储过程中的一致。-->
 42     <!--如果有输出参数,输出参数这行column="idCount",必须写,而且要和存储过程中的输出参数对应-->
 43     <parameterMap id="pageParas" class="Hashtable">
 44       <parameter property="currentPage" column=""/>
 45       <parameter property="pageSize" column="pageSize"/>
 46       <parameter property="idCount" column="idCount" direction="OutPut"/>
 47       <!--输出参数,使用direction描述,也可以省略这个参数-->
 48     </parameterMap>
 49     <parameterMap id="pkAdmin" class="Hashtable">
 50       <parameter property="pk" column="pk"/>
 51     </parameterMap>
 52   </parameterMaps>
 53   <statements>
 54 
 55     <select id="SysAdmin_GetCount" resultClass="System.Int32">
 56       SELECT count(*) FROM [dbo].[SysAdmin]
 57     </select>
 58 
 59     <select id="SysAdmin_FindAll" resultMap="FullResultMap">
 60       SELECT *
 61       FROM [dbo].[SysAdmin]
 62     </select>
 63 
 64     <select id="SysAdmin_Find" parameterClass="String" resultMap="FullResultMap" extends="SysAdmin_FindAll">
 65       WHERE
 66       ([SysAdmin].[PK_Admin] = #PKAdmin,dbType=VarChar#)
 67     </select>
 68 
 69     <select id="SysAdmin_FindAllByCond" parameterClass="SysAdmin" resultMap="FullResultMap">
 70       SELECT * FROM [dbo].[SysAdmin]
 71       <dynamic prepend="WHERE">
 72         <isNotEmpty prepend="and" property="PKAdmin">
 73           PK_Admin=#PKAdmin#
 74         </isNotEmpty>
 75         <isNotEmpty prepend="and" property="PsnCode">
 76           PsnCode=#PsnCode#
 77         </isNotEmpty>
 78         <isNotEmpty prepend="and" property="PsnName">
 79           PsnName=#PsnName#
 80         </isNotEmpty>
 81         <isNotEmpty prepend="and" property="CorpCode">
 82           CorpCode=#CorpCode#
 83         </isNotEmpty>
 84         <isNotEmpty prepend="and" property="CorpName">
 85           CorpName=#CorpName#
 86         </isNotEmpty>
 87         <isNotEmpty prepend="and" property="DeptCode">
 88           DeptCode=#DeptCode#
 89         </isNotEmpty>
 90         <isNotEmpty prepend="and" property="DeptName">
 91           DeptName=#DeptName#
 92         </isNotEmpty>
 93         <isNotEmpty prepend="and" property="Email">
 94           Email=#Email#
 95         </isNotEmpty>
 96         <isNotEmpty prepend="and" property="DomainAccount">
 97           DomainAccount=#DomainAccount#
 98         </isNotEmpty>
 99         <isNotEmpty prepend="and" property="OperaterCode">
100           OperaterCode=#OperaterCode#
101         </isNotEmpty>
102         <isNotEmpty prepend="and" property="OperaterName">
103           OperaterName=#OperaterName#
104         </isNotEmpty>
105         <isNotEmpty prepend="and" property="DEF01">
106           DEF01=#DEF01#
107         </isNotEmpty>
108         <isNotEmpty prepend="and" property="DEF02">
109           DEF02=#DEF02#
110         </isNotEmpty>
111         <isNotNull property="DEF03">
112           <isNotEmpty property="DEF03">
113             <isNotEqual prepend="and" property="DEF03" compareValue="0">
114               DEF03=#DEF03#
115             </isNotEqual>
116           </isNotEmpty>
117         </isNotNull>
118         <isNotNull property="DEF04">
119           <isNotEmpty property="DEF04">
120             <isNotEqual prepend="and" property="DEF04" compareValue="0">
121               DEF04=#DEF04#
122             </isNotEqual>
123           </isNotEmpty>
124         </isNotNull>
125         <isNotEmpty prepend="and" property="DEF05">
126           DEF05=#DEF05#
127         </isNotEmpty>
128         <isNotEmpty prepend="and" property="Dr">
129           Dr=#Dr#
130         </isNotEmpty>
131         <isNotEmpty prepend="and" property="Ts">
132           Ts=#Ts#
133         </isNotEmpty>
134       </dynamic>
135     </select>
136 
137     <insert id="SysAdmin_Insert" parameterClass="SysAdmin">
138       INSERT INTO [dbo].[SysAdmin] (
139       [PsnCode]
140       , [PsnName]
141       , [CorpCode]
142       , [CorpName]
143       , [DeptCode]
144       , [DeptName]
145       , [Email]
146       , [DomainAccount]
147       , [OperaterCode]
148       , [OperaterName]
149       , [DEF01]
150       , [DEF02]
151       , [DEF03]
152       , [DEF04]
153       , [DEF05]
154       , [Dr]
155       , [Ts]
156       ) VALUES (
157       #PsnCode,dbType=VarChar#
158       , #PsnName,dbType=NVarChar#
159       , #CorpCode,dbType=VarChar#
160       , #CorpName,dbType=NVarChar#
161       , #DeptCode,dbType=VarChar#
162       , #DeptName,dbType=NVarChar#
163       , #Email,dbType=VarChar#
164       , #DomainAccount,dbType=NVarChar#
165       , #OperaterCode,dbType=VarChar#
166       , #OperaterName,dbType=NVarChar#
167       , #DEF01,dbType=NVarChar#
168       , #DEF02,dbType=NVarChar#
169       , #DEF03,dbType=Int#
170       , #DEF04,dbType=Int#
171       , #DEF05,dbType=Bit#
172       , #Dr,dbType=Bit#
173       , #Ts,dbType=DateTime#
174       )
175     </insert>
176 
177     <update id="SysAdmin_Update" parameterClass="SysAdmin">
178       UPDATE [dbo].[SysAdmin] SET
179       [PsnCode] = #PsnCode,dbType=VarChar#
180       , [PsnName] = #PsnName,dbType=NVarChar#
181       , [CorpCode] = #CorpCode,dbType=VarChar#
182       , [CorpName] = #CorpName,dbType=NVarChar#
183       , [DeptCode] = #DeptCode,dbType=VarChar#
184       , [DeptName] = #DeptName,dbType=NVarChar#
185       , [Email] = #Email,dbType=VarChar#
186       , [DomainAccount] = #DomainAccount,dbType=NVarChar#
187       , [OperaterCode] = #OperaterCode,dbType=VarChar#
188       , [OperaterName] = #OperaterName,dbType=NVarChar#
189       , [DEF01] = #DEF01,dbType=NVarChar#
190       , [DEF02] = #DEF02,dbType=NVarChar#
191       , [DEF03] = #DEF03,dbType=Int#
192       , [DEF04] = #DEF04,dbType=Int#
193       , [DEF05] = #DEF05,dbType=Bit#
194       , [Dr] = #Dr,dbType=Bit#
195       , [Ts] = #Ts,dbType=DateTime#
196       WHERE
197       ([PK_Admin] = #PKAdmin,dbType=VarChar#)
198     </update>
199     <delete id="SysAdmin_Delete">
200       DELETE FROM [dbo].[SysAdmin]
201       WHERE
202       ([PK_Admin] = #PKAdmin,dbType=VarChar#)
203       ry
204 
205     </delete>
206 
207     <select id="findUsers" parameterClass="HashTable" resultClass="System.Data.DataSet" >
208       select q.PK_Admin,q.PsnCode,q.PsnName
209       from
210       (select t.*, ROW_NUMBER() OVER ( ORDER BY t.PK_Admin) rn
211       from
212       (select a.*
213       from SysAdmin a
214       ) t
215       ) q
216       where <![CDATA[  rn <= #currentPage# * #pageSize# ]]>
217       and  <![CDATA[ rn >(#currentPage# - 1) * #pageSize# ]]>
218     </select>
219 
220     <select id="findCountByCondition" parameterClass="HashTable" resultClass="int" >
221       select count(*)
222       from
223       (select t.*, ROW_NUMBER() OVER ( ORDER BY t.PK_Admin) rn
224       from
225       (select *  from SysAdmin) t
226       ) q
227       where 1=1
228     </select>
229 
230     <select id="findByCondition" parameterClass="HashTable" resultClass="System.Data.DataSet" >
231 
232       <![CDATA[select q.PK_Admin,q.PsnCode,q.PsnName
233       from
234       ( select t.*, ROW_NUMBER() OVER ( ORDER BY t.PK_Admin) rn
235       from
236       (select *  from SysAdmin]]>
237       <dynamic prepend="WHERE">
238         <isNotEmpty prepend="and" property="finCondition">
239           PK_Admin like '%$finCondition$%' OR PsnCode  LIKE   '%$finCondition$%'  OR PsnName like '%$finCondition$%'
240         </isNotEmpty>
241       </dynamic>
242       ) t
243       ) q
244       where 1=1 and
245       <![CDATA[  rn <= #currentPage# * #pageSize# ]]>
246       and  <![CDATA[ rn >(#currentPage# - 1) * #pageSize# ]]>
247       
248       <![CDATA[      
249        select count(*) as total
250       from
251       ( select t.*, ROW_NUMBER() OVER ( ORDER BY t.PK_Admin) rn
252       from
253       (select *  from SysAdmin       
254       ]]>
255       <dynamic prepend="WHERE">
256         <isNotEmpty prepend="and" property="finCondition">
257           PK_Admin like '%$finCondition$%' OR PsnCode  LIKE   '%$finCondition$%'  OR PsnName like '%$finCondition$%'
258         </isNotEmpty>
259       </dynamic>
260       ) t
261       ) q
262     </select>
263 
264     <!--在procedure 中必须设置parameterMap属性,就是存储不带参数也需要设置-->
265     <procedure id="GetPageList" parameterMap="pageParas" resultMap="FullResultMap">
266       UP_GetPage
267     </procedure>
268     <!--存储过程返回的值要和resultMap对应-->
269     <procedure id="GetOne" parameterMap="pkAdmin" resultMap="FullResultMap">
270       UP_GetOne
271     </procedure>
272   </statements>
273 </sqlMap>
View Code

 

posted @ 2015-11-01 16:18  weiqinl  阅读(435)  评论(0编辑  收藏  举报