title: Deleting Realm Objects that are part of other Realm Objects
body: <p>I started trying Realm for Android, so I created two classes:</p>
  
  <pre><code>class ProductSelection extends RealmObject {
  
  private String selectedProductName;
  private String selectedProductID;
  …
  }
  
  
  class ProductProfile extends RealmObject {
  
  private String profileTitle;   
  private RealmList&lt; ProductSelection &gt; productSelection;
  …
  }
  </code></pre>
  
  <p>I then created a couple of ProductSelection Objects and ProductProfile Objects.</p>
  
  <pre><code>  realm.beginTransaction();
      ProductSelection prodSelection = realm.createObject(ProductSelection.class);
      prodSelection.setSelectedProductName(prodTv.getText().toString());
      prodSelection.setSelectedProductID(prodIdTv.getText().toString());
      …
      realm.commitTransaction();
      …
      realm.beginTransaction();
  
      ProductProfile profile = realm.createObject(ProductProfile.class);
      profile.setProfileTitle(“Some Title”);
  
      RealmResults&lt; ProductSelection &gt; results =         
      realm.allObjects(ProductSelection.class);
      RealmList&lt; ProductSelection &gt; selectionList = new RealmList&lt;&gt;();
      for (ProductSelection selection : results) {
      selectionList.add(selection);
      } 
      profile.setProductSelection(selectionList);
  
  realm.commitTransaction();
  </code></pre>
  
  <p>Now I have the following questions:</p>
  
  <ol>
  <li><p>When I call </p>
  
  <pre><code>realm.allObjects(ProductSelection.class).clear(); 
  </code></pre></li>
  </ol>
  
  <p>it seems not only my ProductSelection Objects are cleared but also the List of ProductSelection Objects that are part of ProductProfile Class, as they now don’t hold any Objects anymore. Is it possible to prevent this, that is removing all ProductSelection Objects but still keeping the Objects that are part ProductProfile’s list?</p>
  
  <ol start="2">
  <li>Is the other way around also possible, that is removing ProductProfile Objects without removing ProductSelection Objects, that are not part of the productSelection List?</li>
  </ol>