`
Kevin12
  • 浏览: 236160 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

oracle 使用ibatis动态多条件组合模糊查询

阅读更多
链接地址:http://kevin12.iteye.com/blog/1953571

最近将流程项目数据库由mysql数据库改成oracle数据库时,发现oracle的ibatis配置文件和mysql的ibatis的模糊查询不同,下面记录一下,以备后用。

如果是mysql的模糊查询用:
<isNotEmpty prepend="AND" property="IM_NAME"> a.IM_NAME like concat('%',#IM_NAME#,'%')</isNotEmpty>


如果是oracle的模糊查询用:
<isNotEmpty prepend="AND" property="IM_NAME"> a.IM_NAME like '%'||#IM_NAME#||'%'</isNotEmpty>
或者
<isNotEmpty prepend="AND" property="IM_NAME"> a.IM_NAME like '%$IM_NAME$%'</isNotEmpty>


模糊查询不能用#,#是用prepareStatement的?插入参数,$是文本替换
下面贴出一个ibatis文件供参考:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd">
    <sqlMap namespace="IMenu">
    <typeAlias alias="iMenu" type="com.sense.workflow.model.IMenu" />
    <resultMap id="codeNodeMapping"   class="iMenu">
    <result property="IM_ID" column="IM_ID"  />
    <result property="IM_PARENT_ID" column="IM_PARENT_ID"  />
    <result property="IM_LEVEL" column="IM_LEVEL"  />
    <result property="IM_PATH" column="IM_PATH"  />
    <result property="IM_NAME" column="IM_NAME"  />
    <result property="IM_DESCRIPTION" column="IM_DESCRIPTION"  />
    <result property="IM_URL" column="IM_URL"  />
    <result property="IM_STATUS_CODE" column="IM_STATUS_CODE"  />
    <result property="IM_ORDER" column="IM_ORDER"  />
    <result property="IM_CREATE_DATETIME" column="IM_CREATE_DATETIME"  />
    <result property="IM_LAST_UPDATE_DATETIME" column="IM_LAST_UPDATE_DATETIME"  />
    <result property="IM_LAST_UPDATE_OPERATOR_ID" column="IM_LAST_UPDATE_OPERATOR_ID"  />
    <result property="IM_VERSION" column="IM_VERSION"  />
    <result property="IM_VERSION_DATE" column="IM_VERSION_DATE"  />
    <result property="IM_DATA_STATUS" column="IM_DATA_STATUS"  />
    <result property="IM_IS_ACTIVITY" column="IM_IS_ACTIVITY"  />
    </resultMap>
    <insert id="IMenu_insert" parameterClass="iMenu">
        insert into TB_I_MENU(IM_ID,IM_PARENT_ID,IM_LEVEL,IM_PATH,IM_NAME,IM_DESCRIPTION,IM_URL,IM_STATUS_CODE,IM_ORDER,IM_CREATE_DATETIME,IM_LAST_UPDATE_DATETIME,IM_LAST_UPDATE_OPERATOR_ID,IM_VERSION,IM_VERSION_DATE,IM_DATA_STATUS,IM_IS_ACTIVITY) values(#IM_ID#,#IM_PARENT_ID#,#IM_LEVEL#,#IM_PATH#,#IM_NAME#,#IM_DESCRIPTION#,#IM_URL#,#IM_STATUS_CODE#,#IM_ORDER#,#IM_CREATE_DATETIME#,#IM_LAST_UPDATE_DATETIME#,#IM_LAST_UPDATE_OPERATOR_ID#,#IM_VERSION#,#IM_VERSION_DATE#,#IM_DATA_STATUS#,#IM_IS_ACTIVITY#)
    </insert>
    <update id="IMenu_update" parameterClass="iMenu">
        update TB_I_MENU  
  <dynamic prepend="set">
  <isNotNull prepend=" " property="IM_PARENT_ID"> IM_PARENT_ID = #IM_PARENT_ID# </isNotNull>
  <isNotNull prepend="," property="IM_LEVEL"> IM_LEVEL = #IM_LEVEL# </isNotNull>
  <isNotNull prepend="," property="IM_PATH"> IM_PATH = #IM_PATH# </isNotNull>
  <isNotNull prepend="," property="IM_NAME"> IM_NAME = #IM_NAME# </isNotNull>
  <isNotNull prepend="," property="IM_DESCRIPTION"> IM_DESCRIPTION = #IM_DESCRIPTION# </isNotNull>
  <isNotNull prepend="," property="IM_URL"> IM_URL = #IM_URL# </isNotNull>
  <isNotNull prepend="," property="IM_STATUS_CODE"> IM_STATUS_CODE = #IM_STATUS_CODE# </isNotNull>
  <isNotNull prepend="," property="IM_ORDER"> IM_ORDER = #IM_ORDER# </isNotNull>
  <isNotNull prepend="," property="IM_CREATE_DATETIME"> IM_CREATE_DATETIME = #IM_CREATE_DATETIME# </isNotNull>
  <isNotNull prepend="," property="IM_LAST_UPDATE_DATETIME"> IM_LAST_UPDATE_DATETIME = #IM_LAST_UPDATE_DATETIME# </isNotNull>
  <isNotNull prepend="," property="IM_LAST_UPDATE_OPERATOR_ID"> IM_LAST_UPDATE_OPERATOR_ID = #IM_LAST_UPDATE_OPERATOR_ID# </isNotNull>
  <isNotNull prepend="," property="IM_VERSION"> IM_VERSION = #IM_VERSION# </isNotNull>
  <isNotNull prepend="," property="IM_VERSION_DATE"> IM_VERSION_DATE = #IM_VERSION_DATE# </isNotNull>
  <isNotNull prepend="," property="IM_DATA_STATUS"> IM_DATA_STATUS = #IM_DATA_STATUS# </isNotNull>
  <isNotNull prepend="," property="IM_IS_ACTIVITY"> IM_IS_ACTIVITY = #IM_IS_ACTIVITY# </isNotNull>
  </dynamic>
 
 where IM_ID=#IM_ID#
    </update>
    <update id="IMenu_delete" parameterClass="java.util.ArrayList"></update>
    <select id="IMenu_getObjectById" parameterClass="java.lang.String" resultMap="codeNodeMapping">
        select IM_ID,IM_PARENT_ID,IM_LEVEL,IM_PATH,IM_NAME,IM_DESCRIPTION,IM_URL,IM_STATUS_CODE,IM_ORDER,IM_CREATE_DATETIME,IM_LAST_UPDATE_DATETIME,IM_LAST_UPDATE_OPERATOR_ID,IM_VERSION,IM_VERSION_DATE,IM_DATA_STATUS,IM_IS_ACTIVITY from TB_I_MENU a 
 where IM_ID=#value# 
    </select>
    <select id="IMenu_getList" parameterClass="iMenu" resultMap="codeNodeMapping">
        select IM_ID,IM_PARENT_ID,IM_LEVEL,IM_PATH,IM_NAME,IM_DESCRIPTION,IM_URL,IM_STATUS_CODE,IM_ORDER,IM_CREATE_DATETIME,IM_LAST_UPDATE_DATETIME,IM_LAST_UPDATE_OPERATOR_ID,IM_VERSION,IM_VERSION_DATE,IM_DATA_STATUS,IM_IS_ACTIVITY  from TB_I_MENU a 
  <dynamic prepend="WHERE ">    
    <isNotEmpty prepend="AND" property="IM_ID"> a.IM_ID = #IM_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_PARENT_ID"> a.IM_PARENT_ID = #IM_PARENT_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LEVEL"> a.IM_LEVEL = #IM_LEVEL#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_PATH"> a.IM_PATH like '%'||#IM_PATH#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_NAME"> a.IM_NAME like '%'||#IM_NAME#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_DESCRIPTION"> a.IM_DESCRIPTION like '%'||#IM_DESCRIPTION#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_URL"> a.IM_URL like '%'||#IM_URL#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_STATUS_CODE"> a.IM_STATUS_CODE = #IM_STATUS_CODE#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_ORDER"> a.IM_ORDER = #IM_ORDER#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_CREATE_DATETIME"> a.IM_CREATE_DATETIME = #IM_CREATE_DATETIME#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LAST_UPDATE_DATETIME"> a.IM_LAST_UPDATE_DATETIME = #IM_LAST_UPDATE_DATETIME#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LAST_UPDATE_OPERATOR_ID"> a.IM_LAST_UPDATE_OPERATOR_ID = #IM_LAST_UPDATE_OPERATOR_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_VERSION"> a.IM_VERSION = #IM_VERSION#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_VERSION_DATE"> a.IM_VERSION_DATE = #IM_VERSION_DATE#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_DATA_STATUS"> a.IM_DATA_STATUS = #IM_DATA_STATUS#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_IS_ACTIVITY"> a.IM_IS_ACTIVITY = #IM_IS_ACTIVITY#</isNotEmpty>
  </dynamic>
 order by   IM_CREATE_DATETIME  desc

    </select>
    <select id="IMenu_getListForPage" parameterClass="java.util.HashMap" resultMap="codeNodeMapping">
        select IM_ID,IM_PARENT_ID,IM_LEVEL,IM_PATH,IM_NAME,IM_DESCRIPTION,IM_URL,IM_STATUS_CODE,IM_ORDER,IM_CREATE_DATETIME,IM_LAST_UPDATE_DATETIME,IM_LAST_UPDATE_OPERATOR_ID,IM_VERSION,IM_VERSION_DATE,IM_DATA_STATUS,IM_IS_ACTIVITY from  TB_I_MENU a 
  <dynamic prepend="WHERE ">    
    <isNotEmpty prepend="AND" property="IM_ID"> a.IM_ID = #IM_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_PARENT_ID"> a.IM_PARENT_ID = #IM_PARENT_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LEVEL"> a.IM_LEVEL = #IM_LEVEL#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_PATH"> a.IM_PATH like '%'||#IM_PATH#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_NAME"> a.IM_NAME like '%'||#IM_NAME#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_DESCRIPTION"> a.IM_DESCRIPTION like '%'||#IM_DESCRIPTION#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_URL"> a.IM_URL like '%'||#IM_URL#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_STATUS_CODE"> a.IM_STATUS_CODE = #IM_STATUS_CODE#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_ORDER"> a.IM_ORDER = #IM_ORDER#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_CREATE_DATETIME"> a.IM_CREATE_DATETIME = #IM_CREATE_DATETIME#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LAST_UPDATE_DATETIME"> a.IM_LAST_UPDATE_DATETIME = #IM_LAST_UPDATE_DATETIME#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LAST_UPDATE_OPERATOR_ID"> a.IM_LAST_UPDATE_OPERATOR_ID = #IM_LAST_UPDATE_OPERATOR_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_VERSION"> a.IM_VERSION = #IM_VERSION#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_VERSION_DATE"> a.IM_VERSION_DATE = #IM_VERSION_DATE#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_DATA_STATUS"> a.IM_DATA_STATUS = #IM_DATA_STATUS#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_IS_ACTIVITY"> a.IM_IS_ACTIVITY = #IM_IS_ACTIVITY#</isNotEmpty>
  </dynamic>
  <dynamic prepend="ORDER BY">
        <isNotEmpty property="orderSql">   
            $orderSql$   
        </isNotEmpty>
    </dynamic>   
    <dynamic prepend=" LIMIT ">
        <isNotEmpty property="startRow">
            #startRow#
        </isNotEmpty>
        <isNotEmpty  property="endRow">
            ,#endRow#
        </isNotEmpty>
   </dynamic>

     </select>
    <select id="IMenu_getCount" parameterClass="java.util.HashMap" resultClass="java.lang.Long">
        select count(1) as value from TB_I_MENU a 
  <dynamic prepend="WHERE ">    
    <isNotEmpty prepend="AND" property="IM_ID"> a.IM_ID = #IM_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_PARENT_ID"> a.IM_PARENT_ID = #IM_PARENT_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LEVEL"> a.IM_LEVEL = #IM_LEVEL#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_PATH"> a.IM_PATH like '%'||#IM_PATH#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_NAME"> a.IM_NAME like '%'||#IM_NAME#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_DESCRIPTION"> a.IM_DESCRIPTION like '%'||#IM_DESCRIPTION#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_URL"> a.IM_URL like '%'||#IM_URL#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_STATUS_CODE"> a.IM_STATUS_CODE = #IM_STATUS_CODE#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_ORDER"> a.IM_ORDER = #IM_ORDER#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_CREATE_DATETIME"> a.IM_CREATE_DATETIME = #IM_CREATE_DATETIME#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LAST_UPDATE_DATETIME"> a.IM_LAST_UPDATE_DATETIME = #IM_LAST_UPDATE_DATETIME#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LAST_UPDATE_OPERATOR_ID"> a.IM_LAST_UPDATE_OPERATOR_ID = #IM_LAST_UPDATE_OPERATOR_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_VERSION"> a.IM_VERSION = #IM_VERSION#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_VERSION_DATE"> a.IM_VERSION_DATE = #IM_VERSION_DATE#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_DATA_STATUS"> a.IM_DATA_STATUS = #IM_DATA_STATUS#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_IS_ACTIVITY"> a.IM_IS_ACTIVITY = #IM_IS_ACTIVITY#</isNotEmpty>
  </dynamic>
    </select>
    <select id="IMenu_getListForPage_Time_Order" parameterClass="java.util.HashMap" resultMap="codeNodeMapping">
        select IM_ID,IM_PARENT_ID,IM_LEVEL,IM_PATH,IM_NAME,IM_DESCRIPTION,IM_URL,IM_STATUS_CODE,IM_ORDER,IM_CREATE_DATETIME,IM_LAST_UPDATE_DATETIME,IM_LAST_UPDATE_OPERATOR_ID,IM_VERSION,IM_VERSION_DATE,IM_DATA_STATUS,IM_IS_ACTIVITY from TB_I_MENU a 
  <dynamic prepend="WHERE ">    
    <isNotEmpty prepend="AND" property="IM_ID"> a.IM_ID = #IM_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_PARENT_ID"> a.IM_PARENT_ID = #IM_PARENT_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LEVEL"> a.IM_LEVEL = #IM_LEVEL#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_PATH"> a.IM_PATH like '%'||#IM_PATH#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_NAME"> a.IM_NAME like '%'||#IM_NAME#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_DESCRIPTION"> a.IM_DESCRIPTION like '%'||#IM_DESCRIPTION#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_URL"> a.IM_URL like '%'||#IM_URL#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_STATUS_CODE"> a.IM_STATUS_CODE = #IM_STATUS_CODE#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_ORDER"> a.IM_ORDER = #IM_ORDER#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_CREATE_DATETIME"> a.IM_CREATE_DATETIME = #IM_CREATE_DATETIME#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LAST_UPDATE_DATETIME"> a.IM_LAST_UPDATE_DATETIME = #IM_LAST_UPDATE_DATETIME#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LAST_UPDATE_OPERATOR_ID"> a.IM_LAST_UPDATE_OPERATOR_ID = #IM_LAST_UPDATE_OPERATOR_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_VERSION"> a.IM_VERSION = #IM_VERSION#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_VERSION_DATE"> a.IM_VERSION_DATE = #IM_VERSION_DATE#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_DATA_STATUS"> a.IM_DATA_STATUS = #IM_DATA_STATUS#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_IS_ACTIVITY"> a.IM_IS_ACTIVITY = #IM_IS_ACTIVITY#</isNotEmpty>
  </dynamic>
    <isNotEmpty prepend="AND" property="filterStartTime">
        <![CDATA[a.CREATE_DATETIME >= #filterStartTime#]]>
    </isNotEmpty>
    <isNotEmpty prepend="AND" property="filterEndTime">
        <![CDATA[ a.CREATE_DATETIME <= #filterEndTime# ]]>
    </isNotEmpty>
     <dynamic prepend="ORDER BY">
        <isNotEmpty property="orderSql">   
            $orderSql$   
        </isNotEmpty>
    </dynamic>   
    <dynamic prepend=" LIMIT ">
        <isNotEmpty property="startRow">
            #startRow#
        </isNotEmpty>
        <isNotEmpty  property="endRow">
            ,#endRow#
        </isNotEmpty>
   </dynamic>

     </select>
    <select id="IMenu_getCount_Time_Order" parameterClass="java.util.HashMap" resultClass="java.lang.Long">
        select count(1) as value from TB_I_MENU a  
  <dynamic prepend="WHERE ">    
    <isNotEmpty prepend="AND" property="IM_ID"> a.IM_ID = #IM_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_PARENT_ID"> a.IM_PARENT_ID = #IM_PARENT_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LEVEL"> a.IM_LEVEL = #IM_LEVEL#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_PATH"> a.IM_PATH like '%'||#IM_PATH#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_NAME"> a.IM_NAME like '%'||#IM_NAME#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_DESCRIPTION"> a.IM_DESCRIPTION like '%'||#IM_DESCRIPTION#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_URL"> a.IM_URL like '%'||#IM_URL#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_STATUS_CODE"> a.IM_STATUS_CODE = #IM_STATUS_CODE#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_ORDER"> a.IM_ORDER = #IM_ORDER#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_CREATE_DATETIME"> a.IM_CREATE_DATETIME = #IM_CREATE_DATETIME#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LAST_UPDATE_DATETIME"> a.IM_LAST_UPDATE_DATETIME = #IM_LAST_UPDATE_DATETIME#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LAST_UPDATE_OPERATOR_ID"> a.IM_LAST_UPDATE_OPERATOR_ID = #IM_LAST_UPDATE_OPERATOR_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_VERSION"> a.IM_VERSION = #IM_VERSION#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_VERSION_DATE"> a.IM_VERSION_DATE = #IM_VERSION_DATE#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_DATA_STATUS"> a.IM_DATA_STATUS = #IM_DATA_STATUS#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_IS_ACTIVITY"> a.IM_IS_ACTIVITY = #IM_IS_ACTIVITY#</isNotEmpty>
  </dynamic>
    <isNotEmpty prepend="AND" property="filterStartTime">
        <![CDATA[a.CREATE_DATETIME >= #filterStartTime#]]>
    </isNotEmpty>
    <isNotEmpty prepend="AND" property="filterEndTime">
        <![CDATA[ a.CREATE_DATETIME <= #filterEndTime# ]]>
    </isNotEmpty>
    </select>
    
    <select id="IMenu_getLastVersion"  parameterClass="iMenu" resultClass="java.lang.Integer">
        select max(IM_VERSION) as value   from  TB_I_MENU a
  <dynamic prepend="WHERE ">    
     <isNotEmpty prepend="AND" property="IM_ID"> a.IM_ID = #IM_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_PARENT_ID"> a.IM_PARENT_ID = #IM_PARENT_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LEVEL"> a.IM_LEVEL = #IM_LEVEL#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_PATH"> a.IM_PATH like '%'||#IM_PATH#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_NAME"> a.IM_NAME like '%'||#IM_NAME#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_DESCRIPTION"> a.IM_DESCRIPTION like '%'||#IM_DESCRIPTION#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_URL"> a.IM_URL like '%'||#IM_URL#||'%'</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_STATUS_CODE"> a.IM_STATUS_CODE = #IM_STATUS_CODE#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_ORDER"> a.IM_ORDER = #IM_ORDER#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_CREATE_DATETIME"> a.IM_CREATE_DATETIME = #IM_CREATE_DATETIME#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LAST_UPDATE_DATETIME"> a.IM_LAST_UPDATE_DATETIME = #IM_LAST_UPDATE_DATETIME#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_LAST_UPDATE_OPERATOR_ID"> a.IM_LAST_UPDATE_OPERATOR_ID = #IM_LAST_UPDATE_OPERATOR_ID#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_VERSION"> a.IM_VERSION = #IM_VERSION#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_VERSION_DATE"> a.IM_VERSION_DATE = #IM_VERSION_DATE#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_DATA_STATUS"> a.IM_DATA_STATUS = #IM_DATA_STATUS#</isNotEmpty>
    <isNotEmpty prepend="AND" property="IM_IS_ACTIVITY"> a.IM_IS_ACTIVITY = #IM_IS_ACTIVITY#</isNotEmpty>
  </dynamic>
    </select>
</sqlMap>

链接地址:http://kevin12.iteye.com/blog/1953571
学习地址:http://www.codesky.net/article/201007/167572.html
分享到:
评论

相关推荐

    ibatis动态多条件组合查询

    ibatis动态多条件组合查询 实例 说明

    iBATIS模糊查询

    例如,MySQL使用LIKE谓词,Oracle使用LIKE谓词或REGEXP_LIKE函数,SQL Server使用LIKE谓词或PATINDEX函数。因此,在使用iBATIS进行模糊查询时,需要根据数据库引擎的不同选择合适的查询语句。 3. 优化查询性能:...

    一个完整的oracle+ibatis小项目

    例如,根据条件动态拼接 WHERE 子句,或者在 SQL 语句中使用 Java 变量。 6. **异常处理**:在实际开发中,你可能会遇到各种数据库操作异常,如 SQL 注入、空指针异常等。了解如何正确捕获并处理这些异常是项目稳定...

    ibatis_动态查询条件

    下面是一个简单的示例,演示如何使用 iBatis 的动态查询条件: ```xml select id, note from Product id = #id# note like '%#note#%' ``` 在上面的示例中,我们使用了 `isNotNull` 和 `...

    ibatis+oracle实例

    在IT行业中,数据库管理和持久化框架是至关重要的技术领域,而`ibatis+oracle`的组合就是这样的一个经典实例。Ibatis,一个轻量级的Java ORM(对象关系映射)框架,允许开发者将SQL语句与Java代码分离,提高了数据库...

    ibatis动态SQL标签用法

    iBatis动态SQL标签用法 iBatis是Java持久层框架,提供了动态SQL标签来实现动态查询。动态SQL标签可以根据不同的条件生成...通过使用动态SQL片段和动态条件分页查询,我们可以提高代码的可重用性、查询效率和灵活性。

    oracle 的ibatis驱动程序包

    包含了ibatis及jdbc的驱动,需要的可以下载

    ibatis的动态查询

    以上内容详细介绍了 ibatis 中动态查询的基本原理及具体实现方法,包括模糊查询、多条件组合查询以及使用 Map 作为参数的高级用法。这些知识点对于深入理解 ibatis 的动态查询机制非常重要,可以帮助开发者更高效地...

    IBatis完成单表基本的数据库操作 模糊查询

    标题 "IBatis完成单表基本的数据库操作 模糊查询" 涉及到的是使用iBatis这个轻量级的持久层框架进行数据库的基本操作,特别是模糊查询。iBatis是一个优秀的SQL映射框架,它允许开发者将SQL语句与Java代码分离,提高...

    ORACLE、IBATIS_20100914

    ORACLE、IBATIS_20100914 ORACLE、IBATIS_20100914 ORACLE、IBATIS_20100914

    ibatis下oracle树查询

    在本话题中,我们将探讨如何在使用iBatis框架与Oracle数据库时实现树形查询。 首先,iBatis是一个优秀的持久层框架,它允许开发者将SQL语句直接写在XML配置文件或者注解中,提供了比传统JDBC更高级的抽象层,使得...

    ibatis中使用安全的拼接语句,动态查询,大于、小于、等于.doc

    在 iBatis 中,使用动态 SQL 可以生成安全的拼接语句,避免 SQL 注入攻击。例如,在上面的示例代码中,我们使用 `&lt;dynamic&gt;` 元素来定义动态 SQL 语句,在其中使用 `&lt;isNotNull&gt;`、`&lt;isGreaterThan&gt;`、`&lt;isLessThan&gt;...

    ibatis oracle clob

    标题 "ibatis oracle clob" 涉及到的是在Java开发中,使用iBATIS框架与Oracle数据库交互时处理CLOB(Character Large Object)类型数据的问题。CLOB是Oracle数据库用于存储大文本数据(如XML文档、长篇文章等)的...

    ibatis的实现(包含模糊查询、关联查询、增删改查)

    本篇将详细讲解Ibatis在实现模糊查询、关联查询以及增删改查操作时的关键知识点。 首先,模糊查询是数据库操作中常见的功能,Ibatis通过`&lt;if&gt;`标签或`&lt;where&gt;`标签配合`#{}`占位符来实现。例如,如果你有一个用户...

    iBatis条件查询

    在描述中提到的"按条件查询",就是通过iBatis动态构建SQL语句来实现的。开发者可以在SQL Map中定义一个模板SQL,然后在Java代码中传入参数,iBatis会自动替换SQL中的占位符,生成实际的查询语句。这种方式既避免了硬...

    ibatis调用oracle存储过程分页

    ibatis调用oracle存储过程分页

    07_ibatis教程_模糊查询实体对象.zip

    在本教程"07_ibatis教程_模糊查询实体对象"中,我们将深入学习如何使用iBatis这个流行的Java持久层框架进行模糊查询操作,尤其是在处理实体对象时。iBatis作为一个轻量级的ORM(Object-Relational Mapping)工具,它...

    Ibatis.net+ oracle 简单事例

    "IbatisTet" 可能是一个示例项目,展示了如何在VS2008中使用Ibatis.net 操作Oracle 数据库。该项目可能包含了必要的配置文件(如ibatis.config)、Mapper XML文件以及对应的.NET类,演示了CRUD(创建、读取、更新、...

    ibatis UPDATE 动态XML与insert

    标题 "ibatis UPDATE 动态XML与insert" 涉及到的是MyBatis框架中对数据库数据进行更新(UPDATE)和插入(INSERT)操作的动态XML配置方式。MyBatis是一个优秀的持久层框架,它支持定制化SQL、存储过程以及高级映射,...

    spring+ibatis+oracle分页缓存源码

    在Spring+iBatis的组合中,iBatis作为数据访问层,负责执行SQL查询,与数据库进行交互。通过配置XML映射文件或注解,iBatis能够将Java对象与数据库表进行映射,方便数据的增删改查操作。 Oracle数据库是一个强大的...

Global site tag (gtag.js) - Google Analytics