title: How to handle two database insertions fom a single form in spring/ hibernate?
body: <p>I have 3 model classes,</p>
  
  <pre><code>User.java
  
  public class UserData {
  private Integer userID;
  private String userName;
  private String userPassword;
  //getters and setters..
  </code></pre>
  
  <p>and Permission class like..</p>
  
  <pre><code>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
  </code></pre>
  
  <p>amd module class like,</p>
  
  <pre><code>module.java
  
  public class ModuleData {
  private Integer modId;
  private String modName;
  </code></pre>
  
  <p>I have some modules in my database. When i am creating a new user, i had listed those modules and had added checkboxes to set permissions. When submitting the form, i need to insert user data to user table and his permissions for each module to the Permission table. </p>
  
  <p>Now i had implemented only inserting roles to the database.. my controller is like..</p>
  
  <pre><code>@RequestMapping(value = "/addRole")
      public ModelAndView addNewRole()
      {
          ModelAndView mav = new ModelAndView("addNewRole");
          RoleData role = new RoleData();
          mav.getModelMap().put("roleDataObj", role);
  
          List&lt;ModuleData&gt; moduleList = moduleService.getAllModules();
          mav.getModelMap().addAttribute("ModuleList", moduleList);
          return mav;
      }
  </code></pre>
  
  <p>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.</p>