我想写一个delete语句,但是条件是根据不同情况设置的,所以加了一个变量delType, 想delType=1 按照id删,delType=2 按照name删,delType=3按照type删。
前三种比较好写:
<isEqual prepend="and" property="delType" compareValue="1">
ID=#id#
</isEqual>
<isEqual prepend="and" property="delType" compareValue="2">
NAME=#name#
</isEqual>
<isEqual prepend="and" property="delType" compareValue="3">
TYPE=#type#
</isEqual>但是如果delType不是1、2、3中的任何一个,我还想执行另外一个条件,这样怎么写?或者delType只要是1、2、3当中的任何一个执行相同的语句,这个又怎么写?
前三种比较好写:
<isEqual prepend="and" property="delType" compareValue="1">
ID=#id#
</isEqual>
<isEqual prepend="and" property="delType" compareValue="2">
NAME=#name#
</isEqual>
<isEqual prepend="and" property="delType" compareValue="3">
TYPE=#type#
</isEqual>但是如果delType不是1、2、3中的任何一个,我还想执行另外一个条件,这样怎么写?或者delType只要是1、2、3当中的任何一个执行相同的语句,这个又怎么写?
解决方案 »
- spring jms多线程接收信息
- 一道可以锻炼你思维的笔试题,在线等!!!
- Spring MVC的BindingResult
- 超级简单笔试题,散分咯
- 问题,关于myeclipse自动删除struts.xml
- 急!求《J2EE应用与BEA WebLogic Server第2版》一书配套的源代码
- 修改servlet后不用重启服务器
- java代码执行顺序问题
- 请教 java NIO中non-blocking的问题!!!
- SQLite 总是报no such table
- request.getsession问题
- myeclipse6.5,运行ant,提示"对于名为 build.xml 的外部工具,文件不存在"
如果boolean返回true就删除成功 false就调用别的方法
<sql id="where">
<dynamic prepend="where">
<isNotNull property="id">
<isGreaterEqual prepend="and" property="id"
compareValue="0">
id = #id:int#
</isGreaterEqual>
</isNotNull>
<isNotNull property="title">
<isNotEmpty prepend="and" property="title">
title = #title:varchar#
</isNotEmpty>
</isNotNull>
<isNotNull property="thefile">
<isNotEmpty prepend="and" property="thefile">
thefile = #thefile:varchar#
</isNotEmpty>
</isNotNull>
</dynamic>
</sql>写成非空判断就行了