title: org.codehaus.jackson.map.JsonMappingException: Can not instantiate value of type [simple type, class models.Job] from JSON String
body: <p>i use the playframework and tried to deserialize some json into a java object.
  It worked fine, exept the relationship in the model. I got the following exception</p>
  
  <blockquote>
    <p>enter code hereorg.codehaus.jackson.map.JsonMappingException: Can not
    instantiate value of type [simple type, class models.Job] from JSON
    String; no single-String constructor/factory method (through reference
    chain: models.Docfile["job"])</p>
  </blockquote>
  
  <p>i thought jackson in combination with play could do that:</p>
  
  <p>this is the json</p>
  
  <pre><code>{"name":"asd","filepath":"blob","contenttype":"image/png","description":"asd","job":"1"}
  </code></pre>
  
  <p>and this my code, nothing special:</p>
  
  <pre><code>public static Result getdata(String dataname) {
          ObjectMapper mapper = new ObjectMapper();
          try {
              Docfile docfile = mapper.readValue((dataname), Docfile.class);
              System.out.println(docfile.name);
              docfile.save();
  
          } catch (JsonGenerationException e) {
  
              e.printStackTrace();
  
          } catch (JsonMappingException e) {
  
              e.printStackTrace();
  
          } catch (IOException e) {
  
              e.printStackTrace();
  
          }
  
          return ok();
      }
  </code></pre>
  
  <p>Hope there is help for me, thanks
  Markus</p>
  
  <p>UPDATE:</p>
  
  <p>Docfile Bean:</p>
  
  <pre><code>package models;
  
  import java.util.*;
  
  import play.db.jpa.*;
  import java.lang.Object.*;
  import play.data.format.*;
  import play.db.ebean.*;
  import play.db.ebean.Model.Finder;
  import play.data.validation.Constraints.*;
  import play.data.validation.Constraints.Validator.*;
  
  import javax.persistence.*;
  
  import com.avaje.ebean.Page;
  
  @Entity
  public class Docfile extends Model {
  
      @Id
      public Long id;
  
      @Required
      public String name;
  
      @Required
      public String description;
  
      public String filepath;
  
      public String contenttype;
  
      @ManyToOne
      public Job job;
  
      public static Finder&lt;Long,Docfile&gt; find = new Model.Finder(
              Long.class, Docfile.class
              );
  
  
  
  
      public static List&lt;Docfile&gt; findbyJob(Long job) {
          return find.where()
                  .eq("job.id", job)
                  .findList();
      }
  
      public static Docfile create (Docfile docfile, Long jobid) {
          System.out.println(docfile);
          docfile.job = Job.find.ref(jobid);
          docfile.save();
          return docfile;
      }
  }
  </code></pre>