title: Response not being returned when object is inserted
body: <p>I have some form data and I am using spring boot and I am sending the POST request through AJAX and it is successfully being inserted in database.But,Since it is being inserted in database ,I am expecting the response,But the response is not coming in <strong>console.log(response).</strong></p>
  
  <p>The data of form is successfully inserted on database as my ajax code is:</p>
  
  <pre><code>var employee={
        "iNumber":$("#iNumber").val(),
         "fullName":$("#fullName").val(),
         "joinedDate":$("#joinedDate").val(),
           "position":$("#position").val(),
         "reportsTo":$("#reportsTo").val(),
          "cubicleNo":$("#cubicleNo").val(),
        "jobType":$("#jobType").val()
  };
  
  $.ajax({
                      url: A_PAGE_CONTEXT_PATH + "/insert-emp",
                      method: "post",
                      contentType: "application/json",
                      dataType: "json",
                      data: JSON.stringify(employee),
                        success: function(response) {
                                  console.log(response);
                              }, error: function(response){
                          switch(response.status){
                              case 409:
                              alert("error");
                          }
                      }
                  });
  </code></pre>
  
  <p>The Rest Api is:</p>
  
  <pre><code>package com.ashwin.vemployee.restcontroller;
  
  import com.ashwin.vemployee.model.Employee;
  import com.ashwin.vemployee.response.ResponseMessage;
  import com.ashwin.vemployee.service.EmployeeService;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.http.HttpStatus;
  import org.springframework.http.ResponseEntity;
  import org.springframework.web.bind.annotation.PostMapping;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.ResponseBody;
  import org.springframework.web.bind.annotation.RestController;
  import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
  
  import javax.validation.Valid;
  import java.net.URI;
  
  @RestController
  public class EmployeeController {
  
      @Autowired
      private EmployeeService empService;
  
    @PostMapping("/insert-emp")
      public ResponseEntity&lt;Object&gt; createUser(@Valid @RequestBody Employee employee){
          Employee savedUser= empService.saveEmployee(employee);
  
  
  
          //return status of HTtp after created
         URI location= ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").
                 buildAndExpand(savedUser.getiNumber()).toUri();
         return ResponseEntity.created(location).build();
      }
  }   
  </code></pre>
  
  <p>The service class is:</p>
  
  <pre><code>package com.ashwin.vemployee.service;
  
  import com.ashwin.vemployee.model.Employee;
  import com.ashwin.vemployee.repository.EmployeeRepository;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Service;
  
  @Service
  public class EmployeeService {
  
      @Autowired
      private EmployeeRepository empRepository;
  
      public Employee saveEmployee(Employee employee){
          if(employee.getiNumber()==0){
              empRepository.save(employee);
          }
          else{
              empRepository.save(employee);
          }
          return  employee;
      }
  
  }
  </code></pre>
  
  <p>The repository is:</p>
  
  <pre><code>package com.ashwin.vemployee.repository;
  
  import com.ashwin.vemployee.model.Employee;
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  
  @Repository
  public interface  EmployeeRepository  extends JpaRepository&lt;Employee,Integer&gt; {
  }
  </code></pre>
  
  <p>The data is successfully inserted on database but the response is coming nothing in my <code>console.log(response).</code></p>
  
  <p>My pom.xml is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;parent&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
          &lt;version&gt;2.2.1.RELEASE&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.ashwin&lt;/groupId&gt;
      &lt;artifactId&gt;vemployee&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;name&gt;vemployee&lt;/name&gt;
      &lt;description&gt;Demo project for Spring Boot for offc&lt;/description&gt;
  
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
      &lt;/properties&gt;
  
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
              &lt;optional&gt;true&lt;/optional&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/jstl/jstl --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;jstl&lt;/groupId&gt;
              &lt;artifactId&gt;jstl&lt;/artifactId&gt;
              &lt;version&gt;1.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- needed for jsp --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.apache.tomcat.embed&lt;/groupId&gt;
              &lt;artifactId&gt;tomcat-embed-jasper&lt;/artifactId&gt;
              &lt;version&gt;9.0.27&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!--bootsrap and jquery--&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.webjars&lt;/groupId&gt;
              &lt;artifactId&gt;bootstrap&lt;/artifactId&gt;
              &lt;version&gt;4.3.1&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.webjars&lt;/groupId&gt;
              &lt;artifactId&gt;jquery&lt;/artifactId&gt;
              &lt;version&gt;3.4.0&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!-- https://mvnrepository.com/artifact/org.webjars/bootstrap-datepicker --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.webjars&lt;/groupId&gt;
              &lt;artifactId&gt;bootstrap-datepicker&lt;/artifactId&gt;
              &lt;version&gt;1.7.1&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;!--        &lt;dependency&gt;--&gt;
  &lt;!--            &lt;groupId&gt;com.oracle.ojdbc&lt;/groupId&gt;--&gt;
  &lt;!--            &lt;artifactId&gt;ojdbc8&lt;/artifactId&gt;--&gt;
  &lt;!--            &lt;scope&gt;runtime&lt;/scope&gt;--&gt;
  &lt;!--        &lt;/dependency&gt;--&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;scope&gt;runtime&lt;/scope&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
              &lt;scope&gt;test&lt;/scope&gt;
              &lt;exclusions&gt;
                  &lt;exclusion&gt;
                      &lt;groupId&gt;org.junit.vintage&lt;/groupId&gt;
                      &lt;artifactId&gt;junit-vintage-engine&lt;/artifactId&gt;
                  &lt;/exclusion&gt;
              &lt;/exclusions&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
  
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
                  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  
  &lt;/project&gt;
  </code></pre>
  
  <p>My model class Employee.java is :</p>
  
  <pre><code>package com.ashwin.vemployee.model;
  
  import javax.persistence.*;
  import javax.validation.constraints.NotBlank;
  import java.util.Date;
  
  @Entity
  @Table(name = "employee")
  public class Employee {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Integer iNumber;
  
      @NotBlank
      private String fullName;
  
  //    @NotBlank
      private String joinedDate;
  
      @NotBlank
      private String position;
  
      @NotBlank
      private String reportsTo;
  
      @NotBlank
      private String cubicleNo;
  
      @NotBlank
      private String jobType;
  
  
      public Employee() {
      }
  
      public Integer getiNumber() {
          return iNumber;
      }
  
      public void setiNumber(Integer iNumber) {
          this.iNumber = iNumber;
      }
  
      public String getFullName() {
          return fullName;
      }
  
      public void setFullName(String fullName) {
          this.fullName = fullName;
      }
  
      public String getJoinedDate() {
          return joinedDate;
      }
  
      public void setJoinedDate(String joinedDate) {
          this.joinedDate = joinedDate;
      }
  
      public String getPosition() {
          return position;
      }
  
      public void setPosition(String position) {
          this.position = position;
      }
  
      public String getReportsTo() {
          return reportsTo;
      }
  
      public void setReportsTo(String reportsTo) {
          this.reportsTo = reportsTo;
      }
  
      public String getCubicleNo() {
          return cubicleNo;
      }
  
      public void setCubicleNo(String cubicleNo) {
          this.cubicleNo = cubicleNo;
      }
  
      public String getJobType() {
          return jobType;
      }
  
      public void setJobType(String jobType) {
          this.jobType = jobType;
      }
  
  }
  </code></pre>