title: how to save an entity with a DiscriminatorValue
body: <p>I have two entities <code>User</code> and <code>Candidat</code>, where <code>Candidat</code> extends the class <code>User</code>, as following :</p>
  
  <p><strong>User entity :</strong></p>
  
  <pre><code>@Entity
  @Table(name="users")
  @Inheritance(strategy=InheritanceType.SINGLE_TABLE)
  @DiscriminatorColumn(name="TYPE_USER",discriminatorType=DiscriminatorType.STRING,length=2)
  
  @JsonTypeInfo(use=JsonTypeInfo.Id.NAME,include=JsonTypeInfo.As.PROPERTY,property="type")
  @JsonSubTypes({
      @Type(name="UC",value=Candidat.class)
  })
  
  @XmlSeeAlso({Candidat.class})
  public class User implements Serializable {
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      private Long codeUser;
  //other code ...
  </code></pre>
  
  <p><strong>Candidat entity :</strong></p>
  
  <pre><code>@Entity
  @DiscriminatorValue("UC")
  @XmlType(name = "UC")
  public class Candidat extends User {
      private String codeMassar;
  </code></pre>
  
  <p>and to save a new Candidat I call this repository method :</p>
  
  <pre><code>candidatRepository.save()
  </code></pre>
  
  <p>from : </p>
  
  <pre><code>public interface CandidatRepository extends JpaRepository&lt;Candidat, String&gt; {
  
  }
  </code></pre>
  
  <p>This is my rest service that calls the save method:</p>
  
  <pre><code>@RequestMapping(value = "/candidats", method = RequestMethod.POST)
  public Candidat saveCandidat(@RequestBody Candidat candidat) throws Exception {
      return candidatMetier.saveCandidat(candidat);
  }
  </code></pre>
  
  <p>The problem is when I want to save a new Candidat as following :</p>
  
  <pre><code>{
    "username": "User",
    "password": "123456",
    "email": "user@gmail.com"
  }
  </code></pre>
  
  <p>I get an error saying :</p>
  
  <blockquote>
    <p>Failed to read HTTP message:
    org.springframework.http.converter.HttpMessageNotReadableException:
    Could not read document: Unexpected token (END_OBJECT), expected
    FIELD_NAME: missing property 'type' that is to contain type id  (for
    class org.capvalue.fme.domain.Candidat)</p>
  </blockquote>
  
  <p>What I understand from it that I have to specify the type in the JSON object I'm sending, but I don't think that's necessary because I save a new <code>Candidat</code> which has the <code>@DiscriminatorValue("UC")</code>, so when its <code>save</code> in the <code>User</code> table it will be saved with <code>type='UC'</code> automatically.</p>
  
  <p>how can I solve this ?</p>