Mybatis裡面:
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 U.* from USER_ROLE_AUT
( <foreach collection="maps" item="item" index="index" separator="union all" >
select
RU_ID_SEQ.Nextval,
#{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=CHAR}
from USER_ROLE_AUT
</foreach>
)U
action裡面:
@RequestMapping("roleAutSave")
@ResponseBody
public Map roleAutSave(HttpServletRequest request, HttpSession session)
throws SystemException {
Map<String, Object> rtnmap = null;
Map<String, Object> map = new HashMap<String, Object>();
try {
String ruAutId = request.getParameter("ruAutId");// 獲取到樹形菜單選中的節點
System.out.println(ruAutId);
String[] adeArrs = ruAutId.split(",");
System.out.println(adeArrs);
String ruRoleId = request.getParameter("ruRoleId");// 獲取選中的角色id
String ruUserIns = request.getParameter("ruUserIns");// 獲取登錄的賬號
List<UserRoleAut> ls = new ArrayList<UserRoleAut>();
UserRoleAut ur = null;
for (String ade : adeArrs) {
ur = new UserRoleAut();
ur.setRuRoleId(new Long(ruRoleId));
ur.setRuAutId(new Long(ade));
ur.setRuUserIns(ruUserIns);
ls.add(ur);
}
map.put("maps", ls);
userRoleAutMapper.insert(map);// 保存
userRoleAutMapper.deleteByPrimaryKey();
rtnmap = okMap("roleAut");
} catch (Exception e) {
rtnmap = failMap("roleAut");
e.printStackTrace();
}
return rtnmap;
}
http://blog.csdn.net/strutce/article/details/47755845 from USER_ROLE_AUT 這個 表改成 dual這是oracle數據庫默認的,建議吧序列查詢提出來