yxhxj2006

常用链接

统计

最新评论

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 奋斗成就男人 阅读(395) 评论(0)  编辑  收藏 所属分类: J2EE


只有注册用户登录后才能发表评论。


网站导航: