我有3个模范班
User.java
public class UserData {
private Integer userID;
private String userName;
private String userPassword;
//getters and setters..
和许可类类似..
Permission.java
public class PermissionsData {
private Integer permissionID;
private Integer userID;
private Integer moduleID;
private boolean permissionIsReadOnly;
private boolean permissionIsModify;
private boolean permissionIsFull;
//getters and setters
AMD 模块类如,
module.java
public class ModuleData {
private Integer modId;
private String modName;
我的数据库中有一些模块。 当我创建新用户时, 我列出这些模块并添加了复选框来设置权限。 在提交表单时, 我需要将用户数据插入到用户表格中, 并将每个模块的用户权限插入到权限表格中 。
现在我只把角色插入到数据库... 我的控制器就像...
@RequestMapping(value = "/addRole")
public ModelAndView addNewRole()
{
ModelAndView mav = new ModelAndView("addNewRole");
RoleData role = new RoleData();
mav.getModelMap().put("roleDataObj", role);
List<ModuleData> moduleList = moduleService.getAllModules();
mav.getModelMap().addAttribute("ModuleList", moduleList);
return mav;
}
How can i achieve to add data to two tables on one submit?? i would also like to know about the mapping betwewen modules and permission I am really new to this spring and hibernate. So plz guide me with sample codes.. Thanks in advance.