title: Posting a complete model object to the controller when only few attributes are used in a form
body: <p>I've read somewhere that for spring mvc, it is a expected behavior to get back NULL in case a form does not contain all the attributes of the model object set by the @ModelAttribute annotiation. S how can I use forms that don't have all the fields of the model object and still recieve the whole but updated object back to the post method of the controller.</p>
  
  <p>A short example code of my intention:</p>
  
  <p>Part of the controller:</p>
  
  <pre><code>....
  
      @RequestMapping(value = "/edit/{id}", method = RequestMethod.GET)
      public String editPost(Model model, @PathVariable Integer id) {
          model.addAttribute("editPost", bPostService.getPost(id));
          return "editPost";
      }
  
      @RequestMapping(value = "/edit/{id}", method = RequestMethod.POST)
      public String editProcessPost(Model model, @PathVariable Integer id, @ModelAttribute BPost editPost) {
          bPostService.updatePost(editPost);
          model.addAttribute("posts", bPostService.getPosts());
          return "redirect:/";
      }
  
  ....
  </code></pre>
  
  <p>The entity mapped by hibernate:</p>
  
  <pre><code>@Entity
  @Table(name = "sometable")
  public class BPost {
  
      @Id
      @GeneratedValue
          @Column(name = "id")
      private int id;
  
      @Column(name = "title")
      private String title;
  
      @Column(name = "description")
      private String description;
  
      @Column(name = "text")
      private String text;
  
      @Column(name = "anothertext")
      private String anothertext;
  
      // getters and setters
  }
  </code></pre>
  
  <p>Part of the JSP view:</p>
  
  <pre><code>&lt;form:form method="POST" modelAttribute="editPost" action="${pageContext.request.contextPath}/secure/post/edit/${editPost.id}"&gt;
  &lt;table&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;td&gt;title:&lt;/td&gt;
          &lt;td&gt;&lt;form:input path="title"&gt;&lt;/form:input&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;description:&lt;/td&gt;
          &lt;td&gt;&lt;form:input path="description"&gt;&lt;/form:input&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;text:&lt;/td&gt;
          &lt;td&gt;&lt;form:input path="text"&gt;&lt;/form:input&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;input value="Edit" type="submit"&gt;&lt;/td&gt;
          &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/form:form&gt;
  </code></pre>
  
  <p>As you can see the "anothertext" attribute is not used on the JSP, but I wan't it unchanged returned to the POST method of the controller. Is that possible?</p>
  
  <p>I know some one probably already asked this question, but I cant find the answer to that.</p>
  
  <p>Thank!</p>