title: Invalid property 'stateId' of bean class Could not find field for property during fallback access
body: <p>I'm getting the following error while trying to update a data in DB using SpringBoot</p>
  
  <p><strong>The error is:</strong> <em>org.springframework.beans.NotReadablePropertyException: Invalid property 'stateId' of bean class [com.studawn.model.District]: Could not find field for property during fallback access!</em></p>
  
  <p>I don't know how to fix it.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.CrossOrigin;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.bind.annotation.ResponseBody;
  import org.springframework.web.bind.annotation.RestController;
  
  import com.studawn.exception.StudawnException;
  import com.studawn.model.City;
  import com.studawn.model.State;
  import com.studawn.request.model.DistrictBean;
  import com.studawn.request.model.StatePage;
  import com.studawn.service.callback.StateCityDistrictService;
  import com.studawn.utils.RestUtils;
  
  @CrossOrigin(maxAge = 3600)
  @RestController
  public class StateCityDistrictController&lt;T&gt; extends RestUtils&lt;T&gt; {
  
      @Autowired
      StateCityDistrictService&lt;T&gt; stateCityDistrictService;
  @RequestMapping(value = "/updateState", method = RequestMethod.POST, headers = "Accept=application/json")
      public @ResponseBody Object updateState(@RequestBody State state) {
          try {
              return getSuccessResponse(stateCityDistrictService.updateState(state));
          } catch (StudawnException e) {
              return getErrorResponse(e.getMessage());
          }
      }
  }
  </code></pre>
  
  <p><strong>Service class</strong></p>
  
  <pre><code>    import java.util.ArrayList;
      import java.util.HashMap;
      import java.util.LinkedHashMap;
      import java.util.List;
      import java.util.Map;
  
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.data.domain.PageRequest;
      import org.springframework.data.domain.Pageable;
      import org.springframework.data.domain.Sort;
      import org.springframework.data.domain.Sort.Direction;
      import org.springframework.stereotype.Service;
      import org.springframework.transaction.annotation.Transactional;
  
      import com.studawn.combined.repository.CityRepository;
      import com.studawn.combined.repository.DistrictRepository;
      import com.studawn.combined.repository.StateRepository;
      import com.studawn.exception.StudawnException;
      import com.studawn.model.AdminUser;
      import com.studawn.model.City;
      import com.studawn.model.District;
      import com.studawn.model.State;
      import com.studawn.request.model.DistrictBean;
      import com.studawn.request.model.StatePage;
      import com.studawn.service.callback.StateCityDistrictService;
      import com.studawn.utils.Constant;
      import com.studawn.utils.ErrorCode;
  
      @Service
      public class StateCityDistrictImpl&lt;T&gt; implements StateCityDistrictService&lt;T&gt;, Constant {
  
          @Autowired
          StateRepository stateRepository;
  
          @Autowired
          CityRepository cityRepository;
  
          @Autowired
          DistrictRepository districtRepository;
     @Transactional
      @Override
      public Object updateDistrict(DistrictBean districtBean) throws StudawnException {
          if (districtRepository.isDistrictCodeExists(districtBean.getDistrictCode()) &gt; 0)
              throw new StudawnException(ErrorCode.DISTRICT_CODE_ALREADY_EXISTS);
          else {
              District district = new District();
              district.setDistrictId(districtBean.getDistrictId());
              district.setDistrictName(districtBean.getDistrictName());
              district.setDistrictCode(districtBean.getDistrictCode());
  
              AdminUser adminUser = new AdminUser();
              adminUser.setLogInId(districtBean.getLastUpdatedBy());
              district.setLastUpdatedBy(adminUser);
  
              State state = new State();
              state.setStateId(districtBean.getStateId());
              district.setState(state);
  
              return stateRepository.saveAndFlush(district);
          }
      }
      }
  </code></pre>
  
  <p><strong>District Entity</strong></p>
  
  <pre><code>@Entity
  @Table(name = "district")
  public class District {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "district_id")
      private int districtId;
  
      @Column(name = "district_name", length = 45)
      private String districtName;
  
      @Column(name = "district_code", length = 45)
      private String districtCode;
  
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "created_date", nullable = false, updatable = false)
      @CreatedDate
      private Date dateCreated;
  
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "modified_date")
      @LastModifiedDate
      private Date dateModified;
  
      @JsonBackReference(value = "createdBy")
      @ManyToOne
      @JoinColumn(name = "created_by", updatable = false, nullable = false)
      private AdminUser createdBy;
  
      @JsonBackReference(value = "lastUpdatedBy")
      @ManyToOne
      @JoinColumn(name = "last_updated_by")
      private AdminUser lastUpdatedBy;
  
      @JsonIgnore
      @OneToMany(mappedBy = "district", fetch = FetchType.LAZY)
      private Set&lt;City&gt; cityList;
  
      @JsonBackReference(value = "stateId")
      @ManyToOne
      @JoinColumn(name = "state_id")
      private State state;
      @JsonIgnore
      @OneToMany(mappedBy = "district")
      private Set&lt;Pincode&gt; pincode;
  
      @JsonIgnore
      @OneToMany(mappedBy = "district")
      private List&lt;College&gt; college;
  
      @JsonIgnore
      public Set&lt;City&gt; getCity() {
          return cityList;
      }
  
      public void setCity(Set&lt;City&gt; cityList) {
          this.cityList = cityList;
      }
  
      public String getDistrictCode() {
          return districtCode;
      }
  
      public void setDistrictCode(String districtCode) {
          this.districtCode = districtCode;
      }
  
      public List&lt;College&gt; getCollege() {
          return college;
      }
  
      public void setCollege(List&lt;College&gt; college) {
          this.college = college;
      }
  
      public Set&lt;Pincode&gt; getPincode() {
          return pincode;
      }
  
      public void setPincode(Set&lt;Pincode&gt; pincode) {
          this.pincode = pincode;
      }
  
      public int getDistrictId() {
          return districtId;
      }
  
      public void setDistrictId(int districtId) {
          this.districtId = districtId;
      }
  
      public String getDistrictName() {
          return districtName;
      }
  
      public void setDistrictName(String districtName) {
          this.districtName = districtName;
      }
  
      public Date getDateCreated() {
          return dateCreated;
      }
  
      public void setDateCreated(Date dateCreated) {
          this.dateCreated = dateCreated;
      }
  
      public Date getDateModified() {
          return dateModified;
      }
  
      public void setDateModified(Date dateModified) {
          this.dateModified = dateModified;
      }
  
      public AdminUser getCreatedBy() {
          return createdBy;
      }
  
      public void setCreatedBy(AdminUser createdBy) {
          this.createdBy = createdBy;
      }
  
      public AdminUser getLastUpdatedBy() {
          return lastUpdatedBy;
      }
  
      public void setLastUpdatedBy(AdminUser lastUpdatedBy) {
          this.lastUpdatedBy = lastUpdatedBy;
      }
  
      public Set&lt;City&gt; getCityList() {
          return cityList;
      }
  
      public void setCityList(Set&lt;City&gt; cityList) {
          this.cityList = cityList;
      }
  
      public State getState() {
          return state;
      }
  
      public void setState(State state) {
          this.state = state;
      }
  }
  </code></pre>
  
  <p><strong>State Entity</strong></p>
  
  <pre><code>@Entity
  @Table(name = "state")
  public class State {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "state_id")
      private int stateId;
  
      @Column(name = "state_name", length = 45)
      private String stateName;
  
      @Column(name = "state_code", length = 45)
      private String stateCode;
  
      @JsonIgnore
      @OneToMany(mappedBy = "state", fetch = FetchType.LAZY)
      private Set&lt;City&gt; cityList;
  
      @JsonIgnore
      @OneToMany(mappedBy = "state", fetch = FetchType.LAZY)
      private Set&lt;District&gt; districtList;
  
      @JsonIgnore
      @OneToMany(mappedBy = "state")
      private List&lt;College&gt; college;
  
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "created_date", nullable = false, updatable = false)
      @CreatedDate
      private Date dateCreated;
  
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "modified_date")
      @LastModifiedDate
      private Date dateModified;
  
      @JsonBackReference(value = "createdBy")
      @ManyToOne
      @JoinColumn(name = "created_by", updatable = false, nullable = false)
      private AdminUser createdBy;
  
      @JsonBackReference(value = "lastUpdatedBy")
      @ManyToOne
      @JoinColumn(name = "last_updated_by")
      private AdminUser lastUpdatedBy;
  
      public String getStateCode() {
          return stateCode;
      }
  
      public void setStateCode(String stateCode) {
          this.stateCode = stateCode;
      }
  
      public Date getDateCreated() {
          return dateCreated;
      }
  
      public void setDateCreated(Date dateCreated) {
          this.dateCreated = dateCreated;
      }
  
      public Date getDateModified() {
          return dateModified;
      }
  
      public void setDateModified(Date dateModified) {
          this.dateModified = dateModified;
      }
  
      public AdminUser getCreatedBy() {
          return createdBy;
      }
  
      public void setCreatedBy(AdminUser createdBy) {
          this.createdBy = createdBy;
      }
  
      public AdminUser getLastUpdatedBy() {
          return lastUpdatedBy;
      }
  
      public void setLastUpdatedBy(AdminUser lastUpdatedBy) {
          this.lastUpdatedBy = lastUpdatedBy;
      }
  
      public List&lt;College&gt; getCollege() {
          return college;
      }
  
      public void setCollege(List&lt;College&gt; college) {
          this.college = college;
      }
  
      public int getStateId() {
          return stateId;
      }
  
      public void setStateId(int stateId) {
          this.stateId = stateId;
      }
  
      public String getStateName() {
          return stateName;
      }
  
      public void setStateName(String stateName) {
          this.stateName = stateName;
      }
  
      public void setCityList(Set&lt;City&gt; cityList) {
          this.cityList = cityList;
      }
  
      public Set&lt;City&gt; getCityList() {
          return cityList;
      }
  
      public void setDistrictList(Set&lt;District&gt; districtList) {
          this.districtList = districtList;
      }
  
      public Set&lt;District&gt; getDistrictList() {
          return districtList;
      }
  }
  </code></pre>
  
  <p><strong>District Bean</strong></p>
  
  <pre><code>public class DistrictBean {
  
      private int districtId;
      private String districtName;
      private String districtCode;
      private String createdBy;
      private String lastUpdatedBy;
      private int stateId;
  
      public String getDistrictCode() {
          return districtCode;
      }
  
      public void setDistrictCode(String districtCode) {
          this.districtCode = districtCode;
      }
  
      public String getCreatedBy() {
          return createdBy;
      }
  
      public void setCreatedBy(String createdBy) {
          this.createdBy = createdBy;
      }
  
      public String getLastUpdatedBy() {
          return lastUpdatedBy;
      }
  
      public void setLastUpdatedBy(String lastUpdatedBy) {
          this.lastUpdatedBy = lastUpdatedBy;
      }
  
      public int getStateId() {
          return stateId;
      }
  
      public void setStateId(int stateId) {
          this.stateId = stateId;
      }
  
      public int getDistrictId() {
          return districtId;
      }
  
      public void setDistrictId(int districtId) {
          this.districtId = districtId;
      }
  
      public String getDistrictName() {
          return districtName;
      }
  
      public void setDistrictName(String districtName) {
          this.districtName = districtName;
      }
  }
  </code></pre>
  
  <p><strong>JSON Request</strong></p>
  
  <pre><code>{
  "districtId":1,
  "districtCode":"Chn"    ,
  "districtName":"Chennai",
  "lastUpdatedBy":"arun@xyz.com",
  "stateId":1
  }
  </code></pre>
  
  <p>Thanks in advance!</p>