ibatis mysql数据库 模糊查询 时间大小比较

来源:互联网 发布:晋城广电网络 编辑:程序博客网 时间:2024/04/29 13:37
<resultMap id="logResult" class="com.frame.vo.log.LogVo" >
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="operationType" column="operation_type" />
<result property="operationContent" column="operation_content" />
<result property="operationDate" column="operation_date" />
</resultMap>

 <!--   getLogForPage查询where条件   -->
    <sql id="queryLogWhere"> 
<dynamic prepend="where"> 
<isNotEmpty prepend="and" property="id">
t.id=#id#
</isNotEmpty>
<isNotEmpty prepend="and" property="userId">
t.user_id  like concat('%',#userId#,'%')
</isNotEmpty>

<isNotEmpty prepend="and" property="operationType">
t.operation_type like concat('%',#operationType#,'%')
</isNotEmpty>

<isNotEmpty prepend="and" property="operationContent">
t.operation_content=#operationContent#
</isNotEmpty>
<isNotEmpty prepend="and" property="logDateStart">
<![CDATA[t.operation_date>=#logDateStart#]]> 
</isNotEmpty>
<isNotEmpty prepend="and" property="logDateEnd">
<![CDATA[t.operation_date<=#logDateEnd#]]> 
</isNotEmpty>

</dynamic>
order by t.operation_date desc
   </sql>
<!-- getLogForPage查询入口  -->
<select id="queryLog" parameterClass="java.util.HashMap"  resultMap="logResult">
select id, user_id, operation_type, operation_content, operation_date  from t_m_log  t
<include refid="queryLogWhere" />
<dynamic prepend="">
<isNotNull property="limitStart">
<isNotNull property="limitSize">
limit #limitStart#, #limitSize# 
                 </isNotNull>
</isNotNull>
</dynamic>


</select>
0 0
原创粉丝点击