Mybatis批量添加,页面获取到的值怎么放入List<类>里面

图片说明

6个回答

UserRoleAut ura=new UserRoleAut();
ura.setXXX("11");
record.add(ura)


根据这些条件在UserRoleAut表中查询。

参考
http://www.cnblogs.com/luxiaoxun/p/4035040.html

比如你可以看里面的selectUsersByName的实现,怎么写sql怎么传参数。

qq_22948413
qq_22948413 这个是批量添加的,帮忙看看我Mybatis有没有写错
接近 5 年之前 回复


<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jul 08 10:06:52 CST 2015.
-->

select RU_ID_SEQ.Nextval from USER_ROLE_AUT

  insert into USER_ROLE_AUT 
    (RU_ID,RU_ROLE_ID, RU_AUT_ID, RU_TIME_INS, RU_USER_INS, RU_TIME_LST, RU_USER_LST, RU_STATUS) 
        select RU_ID_SEQ.Nextval,U.* from USER_ROLE_AUT
      <foreach collection="map" item="item" index="key" separator="union all" >  
         select
                #{item.ruRoleId,jdbcType=DECIMAL}, 
                #{item.ruAutId,jdbcType=DECIMAL}, 
                #{item.ruTimeIns,jdbcType=TIMESTAMP}, 
                #{item.ruUserIns,jdbcType=VARCHAR}, 
                #{item.ruTimeLst,jdbcType=TIMESTAMP}, 
                 #{item.ruUserLst,jdbcType=VARCHAR},
                  #{item.ruStatus,jdbcType=DECIMAL}
        from USER_ROLE_AUT
    </foreach>
    )U


<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Wed Jul 08 10:06:52 CST 2015.
-->

select RU_ID_SEQ.Nextval from USER_ROLE_AUT

  insert into USER_ROLE_AUT 
    (RU_ID,RU_ROLE_ID, RU_AUT_ID, RU_TIME_INS, RU_USER_INS, RU_TIME_LST, RU_USER_LST, RU_STATUS) 
        select RU_ID_SEQ.Nextval,U.* from USER_ROLE_AUT
      <foreach collection="map" item="item" index="key" separator="union all" >  
         select
                #{item.ruRoleId,jdbcType=DECIMAL}, 
                #{item.ruAutId,jdbcType=DECIMAL}, 
                #{item.ruTimeIns,jdbcType=TIMESTAMP}, 
                #{item.ruUserIns,jdbcType=VARCHAR}, 
                #{item.ruTimeLst,jdbcType=TIMESTAMP}, 
                 #{item.ruUserLst,jdbcType=VARCHAR},
                  #{item.ruStatus,jdbcType=DECIMAL}
        from USER_ROLE_AUT
    </foreach>
    )U


select RU_ID_SEQ.Nextval from USER_ROLE_AUT

这个是主键id

List里有一个add方法,直接调用即可

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问