title: JPA update parent child
body: <p>I have 2 object person and address. person is parent and address is child.</p>
  
  <ul>
  <li>Person : personPK , status</li>
  <li>Address : addressPK , person_fk, status</li>
  </ul>
  
  <p>My repository is extending JPARepository.
  <code>personRepository.save(person);</code>
  is working fine for insert.
  But when I update the person object by updating status(eg: Active) in both the tables and use <code>personRepository.save(person);</code> My foreign key references(person_fk) is set as null.</p>
  
  <p>My parent class :</p>
  
  <pre><code>@Entity
  @DynamicUpdate
  @Table(name = "person")
  public class Person {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name="person_pk", nullable=false)
      private Long personPK;
      @OneToMany(fetch = FetchType.EAGER, mappedBy = "person",cascade = CascadeType.PERSIST)
      private Set&lt;Address&gt; addresses = new HashSet&lt;&gt;();
      ...
  }
  </code></pre>
  
  <p>And my child class :</p>
  
  <pre><code>@Entity
  @DynamicUpdate
  @Table(name = "address")
  public class Address {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = "address_pk")
      private Long addressPK;
      @ManyToOne
      @JoinColumn(name = "person_fk", referencedColumnName = "person_pk", nullable=false)
      private Address address;
      ...
  }
  </code></pre>
  
  <p>And from my service layer I am updating it using :
  <code>personRepostiry.save(person);</code></p>
  
  <p>Any help what I am doing wrong here?</p>