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

本文介绍了一个具体的MyBatis配置示例,包括resultMap元素的使用及动态SQL的实现方式,如where条件的动态生成。通过示例展示了如何映射数据库字段到Java对象,以及如何构建灵活的SQL查询。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<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>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值