Mapping Error in Hibernate <p>I have prepared an application in Spring Boot</p> <p>I have implemented oneToOne mapping in hibernate between two tables :</p> <p>person and PersonDetail.</p> <p>Now, when I run the program, I get the <strong>following error</strong> :</p> <p>Neither binding result, nor model object available for 'person'.</p> <p>The error is in personform.html , on the fields address and age.</p> <p>//////////////////////////////Controller///////////////////////////////</p> <pre><code>package com.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import com.model.Person; //import com.model.PersonDetail; import com.service.PersonService; @Controller public class PersonController { Person person = new Person(); private PersonService personService; @Autowired public void setPersonService(PersonService personService) { this.personService = personService; } @RequestMapping(value = "/persons", method = RequestMethod.GET) public String list(Model model){ model.addAttribute("persons", personService.listAllPersons()); System.out.println("Returning Persons"); return "persons"; } @RequestMapping("person/{id}") public String showPerson(@PathVariable Integer id, Model model){ model.addAttribute("person", personService.getPersonById(id)); return "personshow"; } @RequestMapping("person/edit/{id}") public String edit(@PathVariable Integer id, Model model){ model.addAttribute("person", personService.getPersonById(id)); return "personform"; } @RequestMapping("person/new") public String newPerson(Model model){ model.addAttribute("person", new Person()); return "personform"; } @RequestMapping(value = "person", method = RequestMethod.POST) public String savePerson(Person person){ personService.savePerson(person); return "redirect:/persons/"; } @RequestMapping("person/delete/{id}") public String delete(@PathVariable Integer id){ personService.deletePerson(id); /*return "redirect:/products";*/ //return "persons"; return "redirect:/persons/"; } } </code></pre> <p>////////////////////////Person-Model///////////////////////////////</p> <pre><code>package com.model; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToOne; @Entity //@Table(name = "person") public class Person{ @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id",unique=true,nullable=false) private Integer id; @Column(name = "name", unique = true, nullable = false, length = 10) private String name; @OneToOne(cascade= CascadeType.ALL) private PersonDetail personDetail; /* public Person(){} public Person(Integer id,String name) { this.id=id; this.name=name; }*/ public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public PersonDetail getPersonDetail() { return personDetail; } public void setPersonDetail(PersonDetail personDetail) { this.personDetail = personDetail; } } </code></pre> <p>////////////////////////////PersonDetail-Model//////////////////////</p> <pre><code>package com.model; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.OneToOne; import javax.persistence.PrimaryKeyJoinColumn; @Entity public class PersonDetail{ @Id @GeneratedValue(strategy=GenerationType.AUTO) private Integer id; @Column(name = "address", nullable = false, length = 20) private String address; @Column(name = "age", nullable = false,length=10) private Integer age; @OneToOne @PrimaryKeyJoinColumn private Person person; /* public PersonDetail() { } public PersonDetail(Integer id,String address,Integer age) { this.id=id; this.address=address; this.age=age; }*/ public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } public String getAddress() { return this.address; } public void setAddress(String address) { this.address = address; } public Integer getAge() { return this.age; } public void setAge(Integer age) { this.age = age; } public Person getPerson() { return person; } public void setPerson(Person person) { this.person = person; } } </code></pre> <p>/////////////////////////////PersonRepository//////////////////////</p> <pre><code>package com.repository; import javax.transaction.Transactional; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import com.model.Person; @Repository @Transactional public interface PersonRepository extends CrudRepository&lt;Person, Integer&gt;{ } </code></pre> <p>//////////////////////PersonDetailReppository/////////////////////</p> <pre><code>package com.repository; import javax.transaction.Transactional; import org.springframework.data.repository.CrudRepository; import org.springframework.stereotype.Repository; import com.model.PersonDetail; @Repository @Transactional public interface PersonDetailRepository extends CrudRepository&lt;PersonDetail, Integer&gt;{ } </code></pre> <p>/////////////////////////////////index.html/////////////////////</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html xmlns:th="http://www.thymeleaf.org"&gt; &lt;head lang="en"&gt; &lt;title&gt;Spring Boot Example&lt;/title&gt; &lt;!-- &lt;th:block th:include="fragments/headerinc :: head"&gt;&lt;/th:block&gt; --&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container"&gt; &lt;div th:fragment="header"&gt; &lt;nav class="navbar navbar-default"&gt; &lt;div class="container-fluid"&gt; &lt;div class="navbar-header"&gt; &lt;a class="navbar-brand" href="#" th:href="@{/}"&gt;Home&lt;/a&gt; &lt;ul class="nav navbar-nav"&gt; &lt;li&gt;&lt;a href="#" th:href="@{/persons}"&gt;Persons&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#" th:href="@{/person/new}"&gt;Create Person&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt;&lt;/nav&gt;&lt;/div&gt; &lt;!-- &lt;div class="container"&gt; --&gt; &lt;!-- &lt;th:block th:include="fragments/header :: header"&gt;&lt;/th:block&gt; --&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>/////////////////////////persons////////////////////////////</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html xmlns:th="http://www.thymeleaf.org"&gt; &lt;head lang="en"&gt; &lt;title&gt;Persons&lt;/title&gt; &lt;th:block th:include="fragments/headerinc :: head"&gt;&lt;/th:block&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container"&gt; &lt;!-- &lt;th:block th:include="fragments/header :: header"&gt;&lt;/th:block&gt; /*/ --&gt; &lt;div th:if="${not #lists.isEmpty(persons)}"&gt; &lt;h2&gt;Person List&lt;/h2&gt; &lt;table class="table table-striped"&gt; &lt;tr&gt; &lt;th&gt;Id&lt;/th&gt; &lt;th&gt;Person Id&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Address&lt;/th&gt; &lt;th&gt;Age&lt;/th&gt; &lt;th&gt;View&lt;/th&gt; &lt;th&gt;Edit&lt;/th&gt; &lt;th&gt;Delete&lt;/th&gt; &lt;/tr&gt; &lt;tr th:each="person : ${persons}"&gt; &lt;td th:text="${person.id}"&gt;&lt;a href="/person/${person.id}"&gt;Id&lt;/a&gt;&lt;/td&gt; &lt;td th:text="${person.id}"&gt;Person Id&lt;/td&gt; &lt;td th:text="${person.name}"&gt;Name&lt;/td&gt; &lt;td th:text="${person.personDetail.address}"&gt;Address&lt;/td&gt; &lt;td th:text="${person.personDetail.age}"&gt;Age&lt;/td&gt; &lt;td&gt;&lt;a th:href="${ '/person/' + person.id}"&gt;View&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a th:href="${'/person/edit/' + person.id}"&gt;Edit&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a th:href="${'/person/delete/' + person.id}"&gt;Delete&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>////////////////////////////////////personform/////////////////////</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html xmlns:th="http://www.thymeleaf.org"&gt; &lt;head lang="en"&gt; &lt;title&gt;Spring Boot Example&lt;/title&gt; &lt;th:block th:include="fragments/headerinc :: head"&gt;&lt;/th:block&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container"&gt; &lt;th:block th:include="fragments/header :: header"&gt;&lt;/th:block&gt; &lt;h2&gt;Person Details&lt;/h2&gt; &lt;div&gt; &lt;!-- th:object="${person}" --&gt; &lt;form class="form-horizontal" th:action="@{/person}" method="post"&gt; &lt;input type="hidden" th:field="*{person.id}"/&gt; &lt;!-- &lt;div class="form-group"&gt; &lt;label class="col-sm-2 control-label"&gt;Person Id:&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;input type="text" class="form-control" th:field="*{id}"/&gt; &lt;/div&gt; &lt;/div&gt; --&gt; &lt;div class="form-group"&gt; &lt;label class="col-sm-2 control-label"&gt;Name:&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;input type="text" class="form-control" th:field="*{person.name}"/&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label class="col-sm-2 control-label"&gt;Address:&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;input type="text" class="form-control" th:field="*{person.address}"/&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label class="col-sm-2 control-label"&gt;Age:&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;input type="text" class="form-control" th:field="*{person.age}"/&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;button type="submit" class="btn btn-default"&gt;Submit&lt;/button&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>///////////////////////////////////personshow///////////////////////</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html xmlns:th="http://www.thymeleaf.org"&gt; &lt;head lang="en"&gt; &lt;title&gt;Person Details&lt;/title&gt; &lt;th:block th:include="fragments/headerinc :: head"&gt;&lt;/th:block&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container"&gt; &lt;!--/*/ &lt;th:block th:include="fragments/header :: header"&gt;&lt;/th:block&gt; /*/--&gt; &lt;h2&gt;Person Details&lt;/h2&gt; &lt;div&gt; &lt;form class="form-horizontal" th:action="@{/person}" th:object="${person}" method="get"&gt; &lt;div class="form-group"&gt; &lt;label class="col-sm-2 control-label"&gt;Person Id:&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;p class="form-control-static" th:text="${id}"&gt;Person Id&lt;/p&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label class="col-sm-2 control-label"&gt;Name:&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;p class="form-control-static" th:text="${person.name}"&gt;name&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label class="col-sm-2 control-label"&gt;Address:&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;p class="form-control-static" th:text="${person.personDetail.address}"&gt;address&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label class="col-sm-2 control-label"&gt;Age:&lt;/label&gt; &lt;div class="col-sm-10"&gt; &lt;p class="form-control-static" th:text="${person.personDetail.age}"&gt;age&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>