title: JSON parse error: Cannot construct instance of `com.example.greetapp.domain.User`
body: <p>I'm using JHipster and I'm running the following curl command:</p>
  
  <blockquote>
    <p>POST/api/gang-users</p>
  </blockquote>
  
  <p>with body:</p>
  
  <pre><code>{
      "role": "member",
      "gang": "3",
      "user": "1"
  }
  </code></pre>
  
  <p>but I get the following error:</p>
  
  <blockquote>
    <p>JSON parse error: Cannot construct instance of
    <code>com.getgreetapp.greetapp.domain.User</code> (although at least one Creator
    exists): no String-argument constructor/factory method to deserialize
    from String value ('1'); nested exception is
    com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot
    construct instance of <code>com.getgreetapp.greetapp.domain.User</code> (although
    at least one Creator exists): no String-argument constructor/factory
    method to deserialize from String value ('1')\n at [Source:
    (PushbackInputStream); line: 4, column: 10] (through reference chain:
    com.getgreetapp.greetapp.domain.GangUser[\"user\"])</p>
  </blockquote>
  
  <p>GangUserResource <code>createGangUser</code></p>
  
  <pre><code>@PostMapping("/gang-users")
      @Timed
      public ResponseEntity&lt;GangUser&gt; createGangUser(@Valid @RequestBody GangUser gangUser) throws URISyntaxException {
          log.debug("REST request to save GangUser : {}", gangUser);
          if (gangUser.getId() != null) {
              throw new BadRequestAlertException("A new gangUser cannot already have an ID", ENTITY_NAME, "idexists");
          }
          User user = userRepository.findById(gangUser.getUser());
          GangUser result = gangUserRepository.save(gangUser);
          return ResponseEntity.created(new URI("/api/gang-users/" + result.getId()))
              .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
              .body(result);
      }
  </code></pre>
  
  <p>GangUser</p>
  
  <pre><code>package com.getgreetapp.greetapp.domain;
  
  import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  import org.hibernate.annotations.Cache;
  import org.hibernate.annotations.CacheConcurrencyStrategy;
  
  import javax.persistence.*;
  import javax.validation.constraints.*;
  
  import java.io.Serializable;
  import java.util.Objects;
  
  /**
   * A GangUser.
   */
  @Entity
  @Table(name = "gang_user")
  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
  public class GangUser implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @NotNull
      @Column(name = "jhi_role", nullable = false)
      private String role;
  
      @ManyToOne
      private Gang gang;
  
      @ManyToOne
      private User user;
  
      public GangUser() {
  
      }
  
      public GangUser(String role, Gang gang, User user)
      {
          this.role = role;
          this.gang = gang;
          this.user = user;
      }
  
      // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getRole() {
          return role;
      }
  
      public GangUser role(String role) {
          this.role = role;
          return this;
      }
  
      public void setRole(String role) {
          this.role = role;
      }
  
      public Gang getGang() {
          return gang;
      }
  
      public GangUser gang(Gang gang) {
          this.gang = gang;
          return this;
      }
  
      public void setGang(Gang gang) {
          this.gang = gang;
      }
  
      public User getUser() {
          return user;
      }
  
      public GangUser user(User user) {
          this.user = user;
          return this;
      }
  
      public void setUser(User user) {
          this.user = user;
      }
      // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
  
      @Override
      public boolean equals(Object o) {
          if (this == o) {
              return true;
          }
          if (o == null || getClass() != o.getClass()) {
              return false;
          }
          GangUser gangUser = (GangUser) o;
          if (gangUser.getId() == null || getId() == null) {
              return false;
          }
          return Objects.equals(getId(), gangUser.getId());
      }
  
      @Override
      public int hashCode() {
          return Objects.hashCode(getId());
      }
  
      @Override
      public String toString() {
          return "GangUser{" +
              "id=" + getId() +
              ", role='" + getRole() + "'" +
              "}";
      }
  }
  </code></pre>
  
  <p>User</p>
  
  <pre><code>package com.getgreetapp.greetapp.domain;
  
  import com.getgreetapp.greetapp.config.Constants;
  
  import com.fasterxml.jackson.annotation.JsonIgnore;
  import org.apache.commons.lang3.StringUtils;
  import org.hibernate.annotations.BatchSize;
  import org.hibernate.annotations.Cache;
  import org.hibernate.annotations.CacheConcurrencyStrategy;
  import javax.validation.constraints.Email;
  
  import javax.persistence.*;
  import javax.validation.constraints.NotNull;
  import javax.validation.constraints.Pattern;
  import javax.validation.constraints.Size;
  import java.io.Serializable;
  import java.util.HashSet;
  import java.util.Locale;
  import java.util.Objects;
  import java.util.Set;
  import java.time.Instant;
  
  /**
   * A user.
   */
  @Entity
  @Table(name = "jhi_user")
  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
  public class User extends AbstractAuditingEntity implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @NotNull
      @Pattern(regexp = Constants.LOGIN_REGEX)
      @Size(min = 1, max = 50)
      @Column(length = 50, unique = true, nullable = false)
      private String login;
  
      @JsonIgnore
      @NotNull
      @Size(min = 60, max = 60)
      @Column(name = "password_hash", length = 60, nullable = false)
      private String password;
  
      @Size(max = 50)
      @Column(name = "first_name", length = 50)
      private String firstName;
  
      @Size(max = 50)
      @Column(name = "last_name", length = 50)
      private String lastName;
  
      @Email
      @Size(min = 5, max = 254)
      @Column(length = 254, unique = true)
      private String email;
  
      @NotNull
      @Column(nullable = false)
      private boolean activated = false;
  
      @Size(min = 2, max = 6)
      @Column(name = "lang_key", length = 6)
      private String langKey;
  
      @Size(max = 256)
      @Column(name = "image_url", length = 256)
      private String imageUrl;
  
      @Size(max = 20)
      @Column(name = "activation_key", length = 20)
      @JsonIgnore
      private String activationKey;
  
      @Size(max = 20)
      @Column(name = "reset_key", length = 20)
      @JsonIgnore
      private String resetKey;
  
      @Column(name = "reset_date")
      private Instant resetDate = null;
  
      @JsonIgnore
      @ManyToMany
      @JoinTable(
          name = "jhi_user_authority",
          joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")},
          inverseJoinColumns = {@JoinColumn(name = "authority_name", referencedColumnName = "name")})
      @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
      @BatchSize(size = 20)
      private Set&lt;Authority&gt; authorities = new HashSet&lt;&gt;();
  
      public User() {}
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getLogin() {
          return login;
      }
  
      // Lowercase the login before saving it in database
      public void setLogin(String login) {
          this.login = StringUtils.lowerCase(login, Locale.ENGLISH);
      }
  
      public String getPassword() {
          return password;
      }
  
      public void setPassword(String password) {
          this.password = password;
      }
  
      public String getFirstName() {
          return firstName;
      }
  
      public void setFirstName(String firstName) {
          this.firstName = firstName;
      }
  
      public String getLastName() {
          return lastName;
      }
  
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  
      public String getImageUrl() {
          return imageUrl;
      }
  
      public void setImageUrl(String imageUrl) {
          this.imageUrl = imageUrl;
      }
  
      public boolean getActivated() {
          return activated;
      }
  
      public void setActivated(boolean activated) {
          this.activated = activated;
      }
  
      public String getActivationKey() {
          return activationKey;
      }
  
      public void setActivationKey(String activationKey) {
          this.activationKey = activationKey;
      }
  
      public String getResetKey() {
          return resetKey;
      }
  
      public void setResetKey(String resetKey) {
          this.resetKey = resetKey;
      }
  
      public Instant getResetDate() {
          return resetDate;
      }
  
      public void setResetDate(Instant resetDate) {
          this.resetDate = resetDate;
      }
  
      public String getLangKey() {
          return langKey;
      }
  
      public void setLangKey(String langKey) {
          this.langKey = langKey;
      }
  
      public Set&lt;Authority&gt; getAuthorities() {
          return authorities;
      }
  
      public void setAuthorities(Set&lt;Authority&gt; authorities) {
          this.authorities = authorities;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) {
              return true;
          }
          if (o == null || getClass() != o.getClass()) {
              return false;
          }
  
          User user = (User) o;
          return !(user.getId() == null || getId() == null) &amp;&amp; Objects.equals(getId(), user.getId());
      }
  
      @Override
      public int hashCode() {
          return Objects.hashCode(getId());
      }
  
      @Override
      public String toString() {
          return "User{" +
              "login='" + login + '\'' +
              ", firstName='" + firstName + '\'' +
              ", lastName='" + lastName + '\'' +
              ", email='" + email + '\'' +
              ", imageUrl='" + imageUrl + '\'' +
              ", activated='" + activated + '\'' +
              ", langKey='" + langKey + '\'' +
              ", activationKey='" + activationKey + '\'' +
              "}";
      }
  }
  </code></pre>
  
  <p>Gang</p>
  
  <pre><code>package com.getgreetapp.greetapp.domain;
  
  import org.hibernate.annotations.Cache;
  import org.hibernate.annotations.CacheConcurrencyStrategy;
  
  import javax.persistence.*;
  import javax.validation.constraints.*;
  
  import java.io.Serializable;
  import java.math.BigDecimal;
  import java.util.Objects;
  
  /**
   * A Gang.
   */
  @Entity
  @Table(name = "gang")
  @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
  public class Gang implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @NotNull
      @Column(name = "name", nullable = false)
      private String name;
  
      @NotNull
      @Column(name = "description", nullable = false)
      private String description;
  
      @NotNull
      @Column(name = "longitude", precision = 10, scale = 2, nullable = false)
      private BigDecimal longitude;
  
      @NotNull
      @Column(name = "latitude", precision = 10, scale = 2, nullable = false)
      private BigDecimal latitude;
  
      @NotNull
      @Column(name = "membership_approval", nullable = false)
      private String membershipApproval;
  
      @NotNull
      @Column(name = "privacy", nullable = false)
      private String privacy;
  
      public Gang() {}
  
      // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public Gang name(String name) {
          this.name = name;
          return this;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getDescription() {
          return description;
      }
  
      public Gang description(String description) {
          this.description = description;
          return this;
      }
  
      public void setDescription(String description) {
          this.description = description;
      }
  
      public BigDecimal getLongitude() {
          return longitude;
      }
  
      public Gang longitude(BigDecimal longitude) {
          this.longitude = longitude;
          return this;
      }
  
      public void setLongitude(BigDecimal longitude) {
          this.longitude = longitude;
      }
  
      public BigDecimal getLatitude() {
          return latitude;
      }
  
      public Gang latitude(BigDecimal latitude) {
          this.latitude = latitude;
          return this;
      }
  
      public void setLatitude(BigDecimal latitude) {
          this.latitude = latitude;
      }
  
      public String getMembershipApproval() {
          return membershipApproval;
      }
  
      public Gang membershipApproval(String membershipApproval) {
          this.membershipApproval = membershipApproval;
          return this;
      }
  
      public void setMembershipApproval(String membershipApproval) {
          this.membershipApproval = membershipApproval;
      }
  
      public String getPrivacy() {
          return privacy;
      }
  
      public Gang privacy(String privacy) {
          this.privacy = privacy;
          return this;
      }
  
      public void setPrivacy(String privacy) {
          this.privacy = privacy;
      }
      // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
  
      @Override
      public boolean equals(Object o) {
          if (this == o) {
              return true;
          }
          if (o == null || getClass() != o.getClass()) {
              return false;
          }
          Gang gang = (Gang) o;
          if (gang.getId() == null || getId() == null) {
              return false;
          }
          return Objects.equals(getId(), gang.getId());
      }
  
      @Override
      public int hashCode() {
          return Objects.hashCode(getId());
      }
  
      @Override
      public String toString() {
          return "Gang{" +
              "id=" + getId() +
              ", name='" + getName() + "'" +
              ", description='" + getDescription() + "'" +
              ", longitude=" + getLongitude() +
              ", latitude=" + getLatitude() +
              ", membershipApproval='" + getMembershipApproval() + "'" +
              ", privacy='" + getPrivacy() + "'" +
              "}";
      }
  }
  </code></pre>