ibatis 開(kāi)發(fā)指南 3
ibatis的調(diào)試相對(duì)困難,出錯(cuò)的時(shí)候主要依據(jù)是log4生成的log文件和.net的出錯(cuò)提示,這方面要能比較熟練的看懂.下面這個(gè)配置基本上包含了最復(fù)雜的功能:分頁(yè)\搜索\排序\緩存\傳值Hash表\返回hash表\動(dòng)態(tài)sql
如果對(duì)下面這段配置能信手粘來(lái)的話,那開(kāi)發(fā)速度將會(huì)大大的提升.
<statement id="XinxiTable_SelectAll" listClass="ArrayList" >
resultMap="SimpleXinxi" parameterClass="Hashtable" cacheModel="xinxi-cache" >
SELECT
<dynamic prepend="top">
<isNotEqual prepend="top" property="TopNum" compareValue = "0">
$TopNum$
</isNotEqual>
</dynamic>
*
FROM
(select a.[iXinxiID],a.[sXinxiTitle],a.[iXinxiClassId],b.[sClassName],
a.[dXinxiDate],a.[dXinxiYxq],a.[iXinxiHits],a.[sXinxiUser],a.[sRedirectUrl],
ROW_NUMBER() OVER(
<dynamic prepend="order by">
<isEqual prepend="order by" property="Sort" compareValue = "0">
a.iXinxiID desc
</isEqual>
<isEqual prepend="order by" property="Sort" compareValue = "1">
a.iXinxiID asc
</isEqual>
<isEqual prepend="order by" property="Sort" compareValue = "2">
a.iXinxiHits desc
</isEqual>
<isEqual prepend="order by" property="Sort" compareValue = "3">
a.iXinxiHits asc
</isEqual>
</dynamic>
) as row
FROM
[dbo].[XinxiTable] as a,[dbo].[XinxiClass] as b
<dynamic prepend="where">
<isParameterPresent>
<isNotEmpty prepend="and" property="XinxiType" >
a.[iXinxiState]= $XinxiType$
</isNotEmpty>
<isNotEqual prepend="and" property="XinxiClass" compareValue = "0">
a.[iXinxiClassID]= $XinxiClass$
</isNotEqual>
<isEqual prepend="and" property="SearchType" compareValue = "1">
a.[sXinxiTitle] LIKE '%$Keyword$%'
</isEqual>
<isEqual prepend="and" property="SearchType" compareValue = "2">
(a.[sXinxiTitle] LIKE '%$Keyword$%' or a.[sXinxiContent] LIKE '%$Keyword$%')
</isEqual>
</isParameterPresent>
</dynamic>
and a.iXinxiClassId=b.iClassId
)a
<dynamic prepend="where">
<isParameterPresent>
<isEqual prepend="and" property="IsPage" compareValue = "1">
row between $PageLower$ and $PageUpper$
</isEqual>
</isParameterPresent>
</dynamic>
</statement>
posted on 2012-09-20 00:55 奮斗成就男人 閱讀(406) 評(píng)論(0) 編輯 收藏 所屬分類: J2EE