您的位置:首页 > 其它

Mybatis查询基础

2016-08-25 15:22 113 查看
批量插入,参数为List
<insert id="addTDRecordBatch" useGeneratedKeys="true" parameterType="java.util.List">
<!-- <selectKey resultType="long" keyProperty="id" order="AFTER">
SELECT
LAST_INSERT_ID()
</selectKey> -->
insert into t_mfts_trade_detection (iTradeDataID,iNameListMark,sNameListStatus,sRuleDetection,sRuleMark,iCreateTime)
values
<foreach collection="list" item="item" index="index" separator="," >
(
#{item.itradeDataID,jdbcType=INTEGER},
#{item.inameListMark,jdbcType=INTEGER},
#{item.snameListStatus,jdbcType=VARCHAR},
#{item.sruleDetection,jdbcType=VARCHAR},
#{item.sruleMark,jdbcType=VARCHAR},
#{item.icreateTime,jdbcType=INTEGER}
)
</foreach>
</insert>
<!-- 插入一条记录 -->
<insert id="insertBatchImportLog" parameterType="java.util.Map">
insert into t_batch_import_log
<trim prefix="(" suffix=")" prefixOverrides="," suffixOverrides=",">
<if test="ioperatorID != null and ioperatorID != '' ">iOperatorID,</if>
<if test="soperatorName != null and soperatorName != '' ">sOperatorName,</if>
<if test="ioperateTime != null ">iOperateTime,</if>
<if test="sbatchTaskName != null and sbatchTaskName != '' ">sBatchTaskName,</if>
<if test="simportFileName != null and simportFileName != '' ">sImportFileName,</if>
<if test="simportErrorFileName != null and simportErrorFileName != '' ">sImportErrorFileName,</if>
<if test="ibatchSucceedNum != null ">iBatchSucceedNum,</if>
<if test="ibatchErrorNum != nul ">iBatchErrorNum,</if>
<if test="icreateTime != null ">iCreateTime,</if>
<if test="(iupdateTime != null) || (icreateTime != null) ">iUpdateTime,</if>
<if test="istatus != null">iStatus,</if>
<if test="ideleteTime != null">iDeleteTime</if>
</trim>
<trim prefix="values(" suffix=")" prefixOverrides="," suffixOverrides=",">
<if test="ioperatorID != null and ioperatorID != '' ">
#{ioperatorID,jdbcType=INTEGER},
</if>
<if test="soperatorName != null and soperatorName != '' ">
#{soperatorName,jdbcType=VARCHAR},
</if>
<if test="ioperateTime != null">
#{ioperateTime,jdbcType=INTEGER},
</if>
<if test="sbatchTaskName != null and sbatchTaskName != '' ">
#{sbatchTaskName,jdbcType=VARCHAR},
</if>
<if test="simportFileName != null and simportFileName != '' ">
#{simportFileName,jdbcType=VARCHAR},
</if>
<if test="simportErrorFileName != null and simportErrorFileName != '' ">
#{simportErrorFileName,jdbcType=VARCHAR},
</if>
<if test="ibatchSucceedNum != null">
#{ibatchSucceedNum,jdbcType=INTEGER},
</if>
<if test="ibatchErrorNum != null">
#{ibatchErrorNum,jdbcType=INTEGER},
</if>
<if test="icreateTime != null">
#{icreateTime,jdbcType=INTEGER},
</if>
<choose>
<when test="iupdateTime != null">
#{iupdateTime,jdbcType=INTEGER},
</when>
<when test="icreateTime != null">
#{icreateTime,jdbcType=INTEGER},
</when>
<otherwise>
</otherwise>
</choose>
<if test="istatus != null">
#{istatus,jdbcType=INTEGER},
</if>
<if test="ideleteTime != null">
#{ideleteTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<!-- 查询批量导入结果 -->
<select id="queryBatchImportLog" parameterType="java.util.Map"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from t_batch_import_log
<where>
<if test="sBatchTaskName != null">
sBatchTaskName = #{sBatchTaskName,jdbcType=VARCHAR}
</if>
<if test="iBeforeThreeMTime != null">
<![CDATA[
and iOperateTime > #{iBeforeThreeMTime,jdbcType=INTEGER}
]]>
</if>
</where>
order by iOperateTime desc
</select>

<!-- 查询(根据主键ID查询) -->
<select id="selectCaseInfoCountByTimeAndType" resultType="com.pingan.haofang.mfts.persistence.CaseInfoCount" parameterType="java.util.Map">
SELECT
<include refid="Base_Column_List" />
FROM t_case_info_count
<where>
<if test="type  != null">
sType=#{type} <!-- 查询的案件类型 -->
</if>
<if test="ableTime != null">
and sAbleTime = #{ableTime} <!-- 计数信息试用的时间 -->
</if>
</where>
for update
</select>

<!-- 查询(按照iUpdateTime between (?,?) and iSentStatus = ‘待发送’ ) -->
<select id="selectPeriodMailsByStatus" resultType="com.pingan.haofang.mfts.persistence.MailList">
SELECT
<include refid="Base_Column_List" />
FROM t_mail_list
WHERE iUpdateTime between #{from} and #{to}
AND
iSentStatus in
<foreach collection="list" item="status" index="index" open="("
close=")" separator=",">
#{status}
</foreach>
</select>

<!-- 修 改 -->
<update id="updateByPrimaryKeySelective" parameterType="com.pingan.haofang.mfts.persistence.MailList">
UPDATE t_mail_list
<set>
<if test="ssubject != null">
sSubject = #{ssubject},
</if>
<if test="sbodyText != null">
sBodyText = #{sbodyText},
</if>
<if test="sbodyEntity != null">
sBodyEntity = #{sbodyEntity},
</if>
<if test="sattachmentURL != null">
sAttachmentURL = #{sattachmentURL},
</if>
<if test="itypeID != null">
iTypeID = #{itypeID},
</if>
<if test="isentStatus != null">
iSentStatus = #{isentStatus},
</if>
<if test="isentTimes != null">
iSentTimes = #{isentTimes},
</if>
<if test="icreateTime != null">
iCreateTime = #{icreateTime},
</if>
<if test="iupdateTime != null">
iUpdateTime = #{iupdateTime},
</if>
<if test="istatus != null">
iStatus = #{istatus},
</if>
<if test="ideleteTime != null">
iDeleteTime = #{ideleteTime},
</if>

</set>
WHERE iAutoId = #{iautoId}
</update>

<!-- 插入明细信息表,并返回主键ID -->
<insert id="insertGetId" parameterType="java.util.Map"  useGeneratedKeys="true" keyProperty="iautoID">
INSERT INTO t_account_check_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="idate != null">iDate,</if>
<if test="ichannelID != null">iChannelID,</if>
<if test="saccountID != null">sAccountID,</if>
<if test="sthirdSerialNum != null">sThirdSerialNum,</if>
<if test="iamount!=null">iAmount,</if>
<if test="iaccChkStatus!=null">iAccChkStatus,</if>
<if test="ibusinessID!=null">iBusinessID,</if>
<if test="itradeTime!=null">iTradeTime,</if>
<if test="sbusinessOrderID!=null">sBusinessOrderID,</if>
<if test="sserialNum != null">sSerialNum,</if>
<if test="ithirdAmount != null">iThirdAmount,</if>
<if test="ifee != null">iFee,</if>
<if test="itransactionType != null">iTransactionType,</if>
<if test="icreateTime != null">iCreateTime</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="idate != null">#{idate,jdbcType=INTEGER},</if>
<if test="ichannelID != null">#{ichannelID,jdbcType=INTEGER},</if>
<if test="saccountID != null">#{saccountID,jdbcType=VARCHAR},</if>
<if test="sthirdSerialNum != null">#{sthirdSerialNum,jdbcType=VARCHAR},</if>
<if test="iamount != null">#{iamount},</if>
<if test="iaccChkStatus != null">#{iaccChkStatus},</if>
<if test="ibusinessID != null">
a893
;#{ibusinessID},</if>
<if test="itradeTime != null">#{itradeTime},</if>
<if test="sbusinessOrderID != null">#{sbusinessOrderID},</if>
<if test="sserialNum != null">#{sserialNum,jdbcType=VARCHAR},</if>
<if test="ithirdAmount != null">#{ithirdAmount,jdbcType=INTEGER},</if>
<if test="ifee != null">#{ifee,jdbcType=INTEGER},</if>
<if test="itransactionType != null">#{itransactionType,jdbcType=INTEGER},</if>
<if test="icreateTime != null">#{icreateTime,jdbcType=INTEGER}</if>
</trim>
</insert>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: