kristain

博客园 首页 新随笔 联系 订阅 管理

ibatis sqlMap.xml 文件 like 查询的三种方案

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMap
PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
"./sql-map-2.dtd">

<sqlMap namespace="Account">
<select id="getAllStudentLike1" resultClass="hashmap" parameterClass="String">
select * from student where name like #name#
<!-- sqlMapClient.queryForList("getAllStudentLike1" , "%张") ; -->
</select>
<select id="getAllStudentLike2" resultClass="hashmap" parameterClass="String">
select * from student where name like '%$name$%'
<!-- sqlMapClient.queryForList("getAllStudentLike2" , "张") ; -->
</select>
<select id="getAllStudentLike3" resultClass="hashmap" parameterClass="String">
select * from student where name like '%'||#name#||'%'
<!-- sqlMapClient.queryForList("getAllStudentLike3" , "张") ; -->
</select>
</sqlMap>
posted on 2012-01-16 14:07  kristain  阅读(509)  评论(0编辑  收藏  举报