ibatis 開發指南 3
ibatis的調試相對困難,出錯的時候主要依據是log4生成的log文件和.net的出錯提示,這方面要能比較熟練的看懂.下面這個配置基本上包含了最復雜的功能:分頁\搜索\排序\緩存\傳值Hash表\返回hash表\動態sql
如果對下面這段配置能信手粘來的話,那開發速度將會大大的提升.
<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 奮斗成就男人 閱讀(407) 評論(0) 編輯 收藏 所屬分類: J2EE