Mybatisに一括挿入してプライマリ・キー・ノートに戻す
1.mapperのコード
形参の前に@Param(「xxxx」)を付けることもできます.
xmlのコード、collectionはlistタイプを記入する必要があります
この文を実行すると、元のusersにプライマリ・キーuserIdが自動的に付きます.
int insertBatchUserReturnId(List users);
形参の前に@Param(「xxxx」)を付けることもできます.
xmlのコード、collectionはlistタイプを記入する必要があります
insert into message (user_id, user_name, user_type, user_passwd, user_phone,user_pic,user_address)
values
#{item.userId,jdbcType=INTEGER}, #{item.userName,jdbcType=VARCHAR}, #{item.userType,jdbcType=TINYINT},
#{item.userPasswd,jdbcType=VARCHAR}, #{item.userPhone,jdbcType=VARCHAR},
#{item.userPic,jdbcType=VARCHAR},#{item.userAddress,jdbcType=VARCHAR}
この文を実行すると、元のusersにプライマリ・キーuserIdが自動的に付きます.