使用#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>