title: Proper way to update a Set element in a JPA @OneToMany relationship?
body: <p>Lets assume we have a <strong>bi-directional One-to-Many relationship</strong> between Parent and Child.</p>
  
  <p>I like the idea of model that relationship with a Set, because of it intrinsic nature of disallowing duplicates.  </p>
  
  <p><strong>Question:</strong><br>
  1) What would be the <strong>proper JPA way</strong> to update a child in such a situation?  </p>
  
  <ul>
  <li>Query the Parent and pass an updated Child into it? </li>
  <li>Query the Child directly and just call its setters?</li>
  </ul>
  
  <p>2) Has either way some <strong>performance</strong> advantages or disadvantages?</p>
  
  <pre><code>@Entity
  public class Parent extends AbstractPersistable&lt;Long&gt; {
  
      @OneToMany(cascade = CascadeType.ALL, ... )
      private Set&lt;Child&gt; children = new HashSet();
  
      public void addChild( Child child ) { ... }
      public void removeChild( Child child ) { ... }
  
      // non-anemic domain model ?
      public void updateChild( Child child ) {
          // how to update the element in the Set?
      }
  }
  </code></pre>
  
  <p><strong>UPDATE:</strong><br>
  How to properly write the update method? Since Sets in Java do not have a get method?</p>