セットコレクションオブジェクトが渡されると、Oraclemybatisがエラーを報告します

起因:

mybatis着信セットコレクションオブジェクトレポート
###データベースの更新中にエラーが発生しました。原因:java.lang.UnsupportedOperationException
###原因:java.lang.UnsupportedOperationException

 

コード

  /**
     * 批量新增
     * @param tbHuidous
     * @return
     */
    int insertTbHuidouRecordsBatch(Set<TbHuidou> tbHuidous);
 <insert id="insertTbHuidouRecordsBatch" parameterType="java.util.Set" useGeneratedKeys="false">
        insert into DZHMONITOR.tb_huidou_records(
        rid,
        hid,
        create_time,
        update_time,
        is_delete
        )
        select DZHMONITOR.SEQ_HUIDOU_RECORDS.nextval as rid,A.* from(
        <foreach collection="set" item="item" index="index"
                 separator="UNION ALL">
            SELECT
            #{item.hid,jdbcType=VARCHAR} as hid,sysdate as  create_time,sysdate as update_time,0 as is_delete
            FROM DUAL
        </foreach>
        ) A
    </insert>

解決策は、@ Param( "set")をインターフェースに追加することです。collection= "set"に対応するパラメーター名を指定する必要があります。

  /**
     * 批量新增
     * @param tbHuidous
     * @return
     */
    int insertTbHuidouRecordsBatch(@Param("set") Set<TbHuidou> tbHuidous);

 

おすすめ

転載: blog.csdn.net/qq_39313596/article/details/108868352