title: map multiple model attributes to a ModelAndView in spring
body: <p>I have tried to implement one-to-many association using spring and hibernate. But I cant implement two model attributes using a single form. How to map two model attributes in a single form.</p>
  
  <p>My controller code is,</p>
  
  <pre><code>    @RequestMapping(value = "/admin/test", method = RequestMethod.GET)
      public ModelAndView adminTestPage(@ModelAttribute("employee") Employee employee, @ModelAttribute("education")Education education, BindingResult result, ModelMap map, Model model) {
  
  
  
          return new ModelAndView("test","command",new Employee());
  }
  </code></pre>
  
  <p>my jsp form is,</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;  
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;  
  &lt;%@taglib  uri="http://www.springframework.org/tags" prefix="spring" %&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form:form method="post" action="saveEmp"&gt;  
          &lt;table &gt;  
            &lt;tr&gt;
            &lt;td&gt;Employee Name : &lt;/td&gt; 
            &lt;td&gt;&lt;form:input path="empName"  /&gt;&lt;/td&gt;
           &lt;/tr&gt;  
           &lt;tr&gt;  
            &lt;td&gt;Address :&lt;/td&gt;  
            &lt;td&gt;&lt;form:input path="empAddress" /&gt;&lt;/td&gt;
           &lt;/tr&gt; 
           &lt;tr&gt;  
            &lt;td&gt;Salary :&lt;/td&gt;  
            &lt;td&gt;&lt;form:input path="salary" /&gt;&lt;/td&gt;
           &lt;/tr&gt;      
           &lt;tr&gt;  
            &lt;td&gt;Salary :&lt;/td&gt;  
            &lt;td&gt;&lt;form:input path="qualification" /&gt;&lt;/td&gt;
           &lt;/tr&gt;   
           &lt;tr&gt;  
            &lt;td&gt;Salary :&lt;/td&gt;  
            &lt;td&gt;&lt;form:input path="stream" /&gt;&lt;/td&gt;
           &lt;/tr&gt;  
  
           &lt;tr&gt;  
            &lt;td&gt;Age :&lt;/td&gt;  
            &lt;td&gt;&lt;form:input path="empAge" /&gt;
            &lt;input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/&gt;&lt;/td&gt;
           &lt;/tr&gt;                       
           &lt;tr&gt;  
            &lt;td&gt; &lt;/td&gt;  
            &lt;td&gt;&lt;input type="submit" value="Save" /&gt;&lt;/td&gt;  
           &lt;/tr&gt;  
          &lt;/table&gt;  
         &lt;/form:form&gt;  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My employee.java entity code is,</p>
  
  <pre><code>@Entity
  @Table(name="Employee")
  public class Employee implements Serializable{
  
      private static final long serialVersionUID = -723583058586873479L;
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      @Column
      private Integer empId;
  
      @Column
      private String empName;
  
  
      @Column
      private String empAddress;
  
      @Column
      private Long salary;
  
      @Column
      private Integer empAge;
  
      @Transient
      private List&lt;Education&gt; education;
      public Integer getEmpId() {
          return empId;
      }
  
      public void setEmpId(Integer empId) {
          this.empId = empId;
      }
  
      public String getEmpName() {
          return empName;
      }
  
      public void setEmpName(String empName) {
          this.empName = empName;
      }
  
      public String getEmpAddress() {
          return empAddress;
      }
  
      public void setEmpAddress(String empAddress) {
          this.empAddress = empAddress;
      }
  
      public Long getSalary() {
          return salary;
      }
  
      public void setSalary(Long salary) {
          this.salary = salary;
      }
  
      public Integer getEmpAge() {
          return empAge;
      }
  
      public void setEmpAge(Integer empAge) {
          this.empAge = empAge;
      }
  
      public List&lt;Education&gt; getEducation() {
          return education;
      }
  
      public void setEducation(List&lt;Education&gt; education) {
          this.education = education;
      }
  
  
  
  
  
  
  
  }
  </code></pre>
  
  <p>Education.java entity is,</p>
  
  <pre><code>@Entity
  @Table(name="Education")
  public class Education{
  
      @Id
      @SequenceGenerator(name = "seq_contacts", sequenceName = "seq_contacts")
      @GeneratedValue(strategy = GenerationType.AUTO, generator = "seq_contacts")
      private int eduID;
  
      @Column
      private String qualification;
  
      @Column
      private String stream;
  
      @ManyToOne
      @JoinColumn(name="empId")
      private Employee employee;
  public Education(){
  
      }
  
      public Education(int eduID, String qualification,String stream, Employee employee )
      {
          super();
          this.eduID = eduID;
          this.qualification = qualification;
          this.stream=stream;
          this.employee = employee;
      }
  
      public int getEduID() {
          return eduID;
      }
  
      public void setEduID(int eduID) {
          this.eduID = eduID;
      }
  
      public String getQualification() {
          return qualification;
      }
  
      public void setQualification(String qualification) {
          this.qualification = qualification;
      }
  
      public String getStream() {
          return stream;
      }
  
      public void setStream(String stream) {
          this.stream = stream;
      }
  
      public Employee getEmployee() {
          return employee;
      }
  
      public void setEmployee(Employee employee) {
          this.employee = employee;
      }
  </code></pre>
  
  <p>Error is,</p>
  
  <pre><code>org.springframework.beans.NotReadablePropertyException: Invalid property 'qualification' of bean class [com.java.web.model.Employee]: Bean property 'qualification' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
      org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:708)
      org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:699)
      org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:99)
      org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:218)
      org.springframework.web.servlet.support.BindStatus.&lt;init&gt;(BindStatus.java:120)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:179)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:199)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:165)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:152)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:143)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:127)
      org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:421)
      org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:142)
      org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:103)
      org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
      org.apache.jsp.WEB_002dINF.pages.test_jsp._jspx_meth_form_005finput_005f4(test_jsp.java:328)
      org.apache.jsp.WEB_002dINF.pages.test_jsp._jspx_meth_form_005fform_005f0(test_jsp.java:169)
      org.apache.jsp.WEB_002dINF.pages.test_jsp._jspService(test_jsp.java:80)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
      org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:264)
      org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
      org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:620)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
      org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
      org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:154)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:199)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.csrf.CsrfFilter.doFilterInternal(CsrfFilter.java:85)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.session.ConcurrentSessionFilter.doFilter(ConcurrentSessionFilter.java:125)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
      org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
      org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
      org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
      org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
      org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
  </code></pre>
  
  <p>Please any one help me to solve this.</p>