iBatis 动态SQL (Dynamic SQL)
来源:互联网 发布:mac usb3.0 编辑:程序博客网 时间:2024/06/06 05:38
英文来自此处
3.9. Dynamic SQL
在ADO里常常遇到的问题就是动态SQL拼接。典型的解决方案是通过if-else语句拼接字符串。iBATIS DataMapper API则提供了一个相对优雅的方式来映射元素。看这个例子:
<select id="dynamicGetAccountList" cacheModel="account-cache" parameterClass="Account" resultMap="account-result" > select * from ACCOUNT <isGreaterThan prepend="and" property="Id" compareValue="0"> where ACC_ID = #Id# </isGreaterThan> order by ACC_LAST_NAME</select>
当参数Id > 0的场合,最终的SQL是:
select * from ACCOUNT where ACC_ID = ? order by ACC_LAST_NAME
当参数Id <= 0的场合,最终的SQL是:
select * from ACCOUNT order by ACC_LAST_NAME
以下面这个例子说明一下动态的标签:
<statement id="someName" parameterClass="Account" resultMap="account-result" > select * from ACCOUNT <dynamic prepend="where"> <isGreaterThan prepend="and" property="id" compareValue="0"> ACC_ID = #id# </isGreaterThan> <isNotNull prepend="and" property="lastName"> ACC_LAST_NAME = #lastName# </isNotNull> </dynamic>order by ACC_LAST_NAME</statement></select>
二元标签属性
二元标签
一元标签属性
一元标签
判空标签属性
判空标签
迭代标签属性
迭代标签
(注意:不要遗漏#UserNameList[]#里面的方括号)
阅读全文
0 0
- iBatis 动态SQL (Dynamic SQL)
- 动态SQL(Dynamic SQL)
- Dynamic SQL(动态SQL)
- ibatis使用dynamic配置动态sql时的问题
- ibatis动态sql入门
- ibatis动态SQL语句
- Ibatis动态SQL语句
- ibatis动态sql
- Ibatis动态SQL语句
- ibatis动态sql
- ibatis动态SQL语句
- ibatis 的动态SQL
- ibatis动态sql
- iBATIS动态SQL
- ibatis 动态sql用法
- ibatis动态sql
- ibatis的动态sql
- ibatis 动态sql总结
- nuxt 引用scss 文件
- SSO单点登录一(Spring+SpringMVC+固定密码)实现的简单的同域SSOdemo
- ffmpeg window下的编译优秀资源
- 网络模型结构的绘制
- 一些js小技巧代码(随时更新)
- iBatis 动态SQL (Dynamic SQL)
- Android 开机动画分析
- 关于Uncaught ReferenceError: $ is not defined的错误
- JavaEE之-Spring详解
- curl 不支持 https
- redis存取各类数据
- extern的使用
- android关于去标题教程和报错解决方案
- ubuntu 14.04下安装openssl