ibatis 組裝動態排序
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
使用#orderstr#是會有問題的,ibatis會自動給你加上單引號,應該使用如下
<dynamic prepend="ORDER BY">
<isNotEmpty property="order">
$order$ $sortDirection$
</isNotEmpty>
</dynamic>
例子:
<select id="getNewsList" resultMap="newsResult" parameterClass="map">
select NEWS_ID,BLOCK_ID,NEWS_TITLE,NEWS_CONTENT,NEWS_SECONDTITLE,NEWS_SUMMARY,NEWS_AUTHOR,NEWS_SOURCE,NEWS_ANNEX,NEWS_TIME,NEWS_OPEN,NEWS_KEYWORDS,NEWS_APPROVE,ISTOP,BROWSENUM,NEWS_COMMENT,NEWS_REFUSE,NEWS_AUDITOR,lasteditor,prjid,prjname,wsflag,MEM_NAME,LASTEDITTIME,ISBLOCKPIC from yc_news where BLOCK_ID = #blockid#
<dynamic prepend="ORDER BY">
<isNotEmpty property="orderstr">
$orderstr$
</isNotEmpty>
</dynamic>
</select>