title: Spring Boot JSON Many to one
body: <p>I have problem with my code...</p>
  
  <p>I create my single page application with Spring Boot and Angularjs.</p>
  
  <p>Here is my users class:</p>
  
  <pre><code>@Entity
  @Table(name = "admins")
  public class Admin {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Integer adminid;
      private String name;
      private String surname;
      private String email;
      private String login;
      private String password;
  
      @ManyToOne
      @JoinColumn(name = "groupid")
      private Group groupid;
      private Boolean active;
      @Temporal(TemporalType.TIMESTAMP)
      private Date modifydate;
      @Temporal(TemporalType.TIMESTAMP)
      private Date createdate;
  
      public Admin() {
      }
     //setters ang getters
    }
  </code></pre>
  
  <p>And my secend entity class looks</p>
  
  <pre><code>@Entity
  @Table(name = "groups")
  public class Group {
  
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Integer groupid;
  private String groupname;
  @Temporal(TemporalType.TIMESTAMP)
  private Date modifydate;
  @Temporal(TemporalType.TIMESTAMP)
  private Date createdate;
  
  @OneToMany(fetch = FetchType.EAGER, mappedBy = "groupid")
  @JsonIgnore
  private List&lt;Admin&gt; groupusers;
  
  public Group() {
  }
  
  public Group(Integer groupid) {
      this.groupid = groupid;
  }
  }
  </code></pre>
  
  <p>My frontend application send request to the server, like this</p>
  
  <pre><code>   {adminid: null, name: "dsa", surname: "dsa", email: "d", login: "sada", groupid: "1", active: true}
  </code></pre>
  
  <p>I have problem with groupid property when i try add new admin...</p>
  
  <pre><code> WARN 27742 --- [nio-8080-exec-8] .w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message: org.springframework.http.converter.HttpMessageNotReadableException: Could not read document: Can not construct instance of com.patryk.model.Group: no String-argument constructor/factory method to deserialize from String value ('1')
    at [Source: java.io.PushbackInputStream@9fe378; line: 1, column: 83] (through reference chain: com.patryk.model.Admin["groupid"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of com.patryk.model.Group: no String-argument constructor/factory method to deserialize from String value ('1')
    at [Source: java.io.PushbackInputStream@9fe378; line: 1, column: 83] (through reference chain: com.patryk.model.Admin["groupid"])
  </code></pre>
  
  <p>My controller:</p>
  
  <pre><code> @RestController
   @RequestMapping("/api/admins")
   public class AdminController {
  
  @Autowired
  private AdminService adminService;
  
  
  @RequestMapping(method = RequestMethod.POST)
  public ResponseEntity&lt;?&gt; addUser(@RequestBody Admin admin)
  {
      adminService.save(admin);
      return new ResponseEntity&lt;Admin&gt; (admin,HttpStatus.OK);
  }
  }
  </code></pre>
  
  <p>How can I find a solution? Anyone know what i am doing wrong ?</p>