title: @OneToMany and @ManyToOne Jpa
body: <p>In my spring JPA project I have two entities, Task and Developer. List can assign to a Developer and one Task can have just one Developer. I mapped them:</p>
  <p><strong>Developer</strong></p>
  <pre><code>@Entity
  @Table(name = &quot;DEVELOPER&quot;)
  public class Developer implements Serializable {
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
      private String name;
  
      @OneToMany(targetEntity = Task.class , mappedBy = &quot;developer&quot;,cascade=CascadeType.ALL, fetch = FetchType.LAZY)
      private List&lt;Task&gt; taskList;
  </code></pre>
  <p><strong>Task</strong></p>
  <pre><code>@Entity
  @Table(name = &quot;TASK&quot;)
  public class Task implements Serializable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long taskId;
      private String taskTitle;
  
      @ManyToOne
      @JoinColumn(name=&quot;developer_id&quot;)
      private Developer developer;
  </code></pre>
  <p>When I assign a List of Task to a Developer, JSON format is:</p>
  <pre><code>{
      &quot;id&quot;: 1,
      &quot;name&quot;: &quot;John&quot;,
      &quot;taskList&quot;: [
          {
              &quot;taskId&quot;:2,
              &quot;taskTitle&quot;: &quot;Do sth&quot;
          }
          ]
  }
  </code></pre>
  <p>But the value of Developer in above Task object is null:</p>
  <pre><code>{
    &quot;taskId&quot;:2,
     &quot;taskTitle&quot;: &quot;Do sth&quot;,
     &quot;developer&quot;: null
  }
  </code></pre>
  <p>I expect to this developer property is not null and Developer and task have a bidirectional relationship.
  How can I solve this? I am new in Spring and Hibernate. Any help would be greatly appreciated.</p>