title: Unable to return JSON from Hibernate POJO in Spring Boot REST
body: <p>I am trying to create a basic REST service using Spring Boot that returns POJOs created from a database using Hibernate and then are transformed into JSON and returned to the REST call.</p>
  
  <p>I can get regular non-Hibernate POJOs to be returned as JSON, but for Hibernate objects I am getting this error:</p>
  
  <pre><code>Failed to write HTTP message: org.springframework.http.converter.HttpMessageNotWritableException: Could not write JSON: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS); nested exception is com.fasterxml.jackson.databind.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: com.example.springboottest.model.Person_$$_jvst48e_0["handler"])
  </code></pre>
  
  <p>Here is my code:</p>
  
  <p><strong>Person.java</strong></p>
  
  <pre><code>@Entity
  @Table(name = "people")
  public class Person implements Serializable {
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private long id;
  
  private String nameLast;
  private String nameFirst;
  
  @Temporal(TemporalType.DATE)
  private Date dob;
  
  protected Person(){}
  
  public Person(String nameLast, String nameFirst, Date dob) {
      this.nameLast = nameLast;
      this.nameFirst = nameFirst;
      this.dob = dob;
  }
  
  // Getters and Setters...
  </code></pre>
  
  <p><strong>PersonRepository.java</strong></p>
  
  <pre><code>@Repository
  public interface PersonRepository extends JpaRepository&lt;Person, Long&gt;{
  
  }
  </code></pre>
  
  <p><strong>PersonController.java</strong></p>
  
  <pre><code>@RestController
  public class PersonController {
  
      @Autowired
      PersonRepository personRepository;
  
      @GetMapping("/person/{id:\\d+}")
      public Person getPersonByID(@PathVariable long id){
          return personRepository.getOne(id);
      }
  }
  </code></pre>
  
  <p>If someone could help me understand why this is not working, it would be very much appreciated. Thanks!</p>