您的位置:首页 > 数据库 > MySQL

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

2015-04-03 10:53 549 查看
<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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ibatis mysql