在项目中使用了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 <= trunc(sysdate)
and hrp.end_time >= trunc(sysdate)
order by hrp.PRIORITY_DISPLAY
</select>tomcatibatismavensqldynamic
<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 <= trunc(sysdate)
and hrp.end_time >= trunc(sysdate)
order by hrp.PRIORITY_DISPLAY
</select>tomcatibatismavensqldynamic
解决方案 »
- 请教关于防止url跳转的问题
- struts2的标签<s:iterator value="list"/> 我能通过索引取值吗?
- 真诚求助hibernate3.2的问题
- 求助,jxl高人,很妖的问题,抓狂了。
- 关于fckeditor的小问题? (没分了,多包含)
- struts中, <action path="/yy" forward="xx.jsp"....这个xx.jsp之前一定要加"/",即使它与/yy.do位于同一路径?
- 一个过滤器应用的奇怪问题,取不到 getParameter();
- 如何控制浏览器的回退功能
- 请大家看一看我的jsp代码,为什么不能使用?
- 一个白送分的帖子,怎么调试jsp
- eclipse 中 打开pom.xml文件后关闭报错
- 设置http请求头,点击链接时候直接打开excel而不是显示下载框
<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>上面对应的字段是否为空?
dynamic 会自动去除第一个 prepend="and中的内容(这里为and)
是我把项目的发布输出路径给设置错了。
我把class和test-class都设置成可以输出到tomcat中,导致test-class中的文件把class中的相同文件给覆盖了