mybatis区别insert与insertSelective

有些为空的插入不进来,可以用selective进行插入。
<insert id="insert" parameterType="com.yonghui.ccd.center.model.CostTplDO">
  <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
    SELECT LAST_INSERT_ID()
  </selectKey>
  insert into yh_cost_tpl (contract_type, tpl_ranking, cost_code,
  cost_name, region_identifier, institutional_format,
  calculation_params, calculation_method, settle_interval,
  calculation_level, default_value, indicators_identifier,
-------------------------------------------------------------
<insert id="insertSelective" parameterType="com.yonghui.ccd.center.model.CostTplDO">
  <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
    SELECT LAST_INSERT_ID()
  </selectKey>
  insert into yh_cost_tpl
  <trim prefix="(" suffix=")" suffixOverrides=",">
    <if test="contractType != null">
      contract_type,
    </if>
    <if test="tplRanking != null">
      tpl_ranking,
    </if>



发表评论

邮箱地址不会被公开。 必填项已用*标注