Mybatis oracle batch批量插入 带序列
void insertZcodeList(@Param("pid")Long pid,@Param("list") List<ActWechatZcode> list);
<insert id="insertZcodeList" parameterType="java.util.List">
insert into ACT_WECHAT_ZCODE${pid} (ID, MICROCODE, SOURCE_CODE,
INDEX_CODE, ORCODE, SECTIONID
)
select SEQ_ACT_WECHAT_ZCODE.nextval as ID, C.* from
(
<foreach collection="list" item="as" index="index" separator="UNION ALL">
select
#{as.microcode,jdbcType=VARCHAR} as MICROCODE,
#{as.sourceCode,jdbcType=VARCHAR} as SOURCE_CODE,
#{as.indexCode,jdbcType=DECIMAL} as INDEX_CODE,
#{as.orcode,jdbcType=VARCHAR} as ORCODE,
#{as.sectionid,jdbcType=DECIMAL} as SECTIONID
from dual
</foreach>
) C
</insert>
<insert id="insertBatchOrderCode" parameterType="java.util.List" useGeneratedKeys="false">
insert into ORDER_INFO_CODE (P_ID, ORDER_ID, PRODUCT_ID, NUM, CREATE_TIME, UPDATE_TIME, CREATOR_ID, UPDATER_ID, PRODUCT_BATCH, LOGISTICS_CODE, CODE_TYPE, IN_OR_OUT_NO)
<foreach collection="codes" item="it" index="index" open="(" close=")" separator="union all">
select
#{it.pId,jdbcType=DECIMAL},
#{it.orderId,jdbcType=DECIMAL},
#{it.productId,jdbcType=DECIMAL},
#{it.num,jdbcType=DECIMAL},
#{it.createTime,jdbcType=TIMESTAMP},
#{it.updateTime,jdbcType=TIMESTAMP},
#{it.creatorId,jdbcType=DECIMAL},
#{it.updaterId,jdbcType=DECIMAL},
#{it.productBatch,jdbcType=VARCHAR},
#{it.logisticsCode,jdbcType=VARCHAR},
#{it.codeType,jdbcType=DECIMAL},
#{it.inOrOutNo,jdbcType=VARCHAR}
from DUAL
</foreach>
</insert>
MYBATIS IN 多参数查询
IN
orgIds in
<foreach item="item" index="index" collection="param.orgIds" open="(" separator="," close=")">
#{item}
</foreach>
原符号 < <= > >= & ' "
替换符号 < <= > >= & ' "
特定格式时间查询
<if test=" startTime !=null and startTime !=''">
and DATE_FORMAT(u.createtime,'%Y-%m-%d') >= #{startTime,jdbcType=VARCHAR}
</if>
<if test=" endTime !=null and endTime !=''">
and DATE_FORMAT(u.createtime,'%Y-%m-%d') <= #{endTime,jdbcType=VARCHAR}
</if>
if else
and a.DEALER_ID = #{param.dealerId}
and a.DEALER_ID IN (
<if test="param.isEnable!=null ">
AND jo.P_ID =#{param.isEnable}
</if>
List 做中间表查数据
select distinct d.code
from
(
<foreach collection="codelist" item="item" index="index" separator="union all">
select
#{item} as code
from dual
</foreach>
) d