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

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

 原: dtd 位置 "http://ibatis.apache.org/dtd/sql-map-2.dtd">

<?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>

相关推荐