日期:2014-05-17  浏览次数:20749 次

ibatis的动态语句发布到tomcat中后丢失
在项目中使用了ibatis的dynamic动态语句,如下
<select id="getRecommends" parameterClass="java.util.Map" resultClass="Long">
select hrp.product_id
 from HOT_RECOMMEND_PRODUCT hrp
 where hrp.category_id = #categoryId#
    and hrp.mc_site_id = #mcsiteId# 
   <![CDATA[
           and hrp.start_time >= trunc(sysdate)
           and hrp.end_time <= trunc(sysdate)
           ]]>
  <dynamic prepend="and">
  <isNotNull prepend="and" property="merchantId">
     hrp.merchant_id like '%' || #merchantId# || '%'
    </isNotNull>
           <isNotEqual prepend="and" property ="siteType" compareValue="0">
           hrp.site_type = #siteType#
           </isNotEqual>
           <isEqual prepend="or" property="siteType" compareValue="0">
           hrp.merchant_id is null
           </isEqual>
  </dynamic>
 order by hrp.PRIORITY_DISPLAY
</select>

本项目为一个maven项目,编译成功后,在target下找到对应的文件中的sql语句,是正常的(同上)。

但是部署到tomcat中后,再找到对应文件中的sql语句,就成了下面的这个样子了
<select id="getRecommends" parameterClass="java.util.Map" resultClass="Long">
select hrp.product_id
 from HOT_RECOMMEND_PRODUCT hrp
 where hrp.category_id = #categoryId#
    and hrp.merchant_id like '%' || #merchantId# || '%'
    and hrp.mc_site_id = #mcsiteId# 
           and hrp.start_time &lt;= trunc(sysdate)
           and hrp.end_time &gt;= trunc(sysdate)
 order by hrp.PRIORITY_DISPLAY
</select>
tomcat ibatis maven sql dynamic

------解决方案--------------------
动态生成的吧...你试试运行发出的对不对就好了呗...