在ibatis 拼接sql语句
金蝶云社区-daniel_liu
daniel_liu
0人赞赏了该文章 889次浏览 未经作者许可,禁止转载编辑于2015年09月23日 23:39:56
Ibatis允许程序员自己编写SQL语句来实现DAO层的操作,让dao层的操作更加灵敏而方便,ibatis中还提供动态拼接sql方式,这样开发者可以减少很多sql的编写。如下代码:<select id="selectAllProducts" parameterClass="Product" resultMap="ProductResult">
select id,note from Product
<dynamic prepend="WHERE">

<isNotNull property="id">

<isGreaterThan prepend=" and " property="id" compareValue="0">
id = #id#
isGreaterThan>
isNotNull>

<isNotEmpty prepend=" and " property="note">

note like '%$note$%'
isNotEmpty>
dynamic>
select>