您的位置:首页 > 数据库

ibatis动态sql配置(in实例,模糊查询等)

2014-08-04 15:00 603 查看
示例1:in

(1)、xml文件配置:

<select id="getSearchIpForWeb" resultClass="com.poson.dacs.util.IgnoreCaseMap">
select f.frame_id as frame_id, f.frame_code as c_name, o.org_id
as org_id, o.org_name as org_name, f.frame_code as frame_code,
'' as port_name ,'' as pool_id from tb_rm_frame f, tb_sm_organ o
where 1 = 1 and f.org_id = o.org_id
<isPropertyAvailable prepend=" AND " property="frameAddr">
f.frame_addr
 <iterate prepend=" in " property="frameAddr" open="("
close=")" conjunction=",">
#frameAddr[]#
</iterate>
</isPropertyAvailable>
order by o.org_id,f.frame_code

</select>

(2)、jsp编写:

<tr id="frameAddrTr">

        <td nowrap="nowrap" align="right" style="background-color: white;">
输入ip(一台或多台Bras):

        </td>

        <td align="left" nowrap="nowrap">
<textarea rows="300" id="frameAddr" name="frameParam2.frameAddr" class="seach_setext">

                ${frameParam.frameAddr}

            </textarea>

         </td>

</tr>

(3)、方法:

public List searchByIp(List frameAddr, int skip, int max){

            try {

            Map param = new HashMap();

                param.put("frameAddr", frameAddr);

                List list = this.publicDAO.selectBySqlMapId("getSearchIpForWeb",param,skip,max);

                return list;
} catch (Exception e) {
   e.printStackTrace();
}
return null;

            }

示例2:模糊查询

(1)、模糊查询

<isPropertyAvailable property="note" >

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

        ( note like '%$note$%')

     </isNotEmpty>

</isPropertyAvailable>

注:模糊查询不能用#,#在是用prepareStatement的?插入参数,$是文本替换
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: