title: How to remove a specific element from ArrayList in morphia?
body: <p>I am using inherited <code>@Embedded</code> reference of ArrayList in Morphia <code>Entity</code> class.</p>
  
  <pre><code>@Entity
  public class First {
    @Embedded private List&lt;Second&gt; secondClass;
    private String title;
    private Long id;
    ...  getter and setter .. methods
  }
  
  @Embedded
  public class Second {
    @Embedded private List&lt;Third&gt; thirdClass;
    private String titleSecond;
    ...  getter and setter .. methods
  }
  
  @Embedded
  public class Third {
    private String titleThird;
    private String logoUrl
    ...  getter and setter .. methods
  }
  </code></pre>
  
  <h1>Json</h1>
  
  <pre><code>{
    "secondClass": [{
      "thirdClass": [{
        "titleThird": "Java",
        "logoUrl": "http://www.artsfon.com/pic/201510//artsfon.com-72885.jpg",
      }, {
        "titleThird": "ios",
        "logoUrl": "http://www.artsfon.com/pic//1920x1080/artsfon.com-72885.jpg",
      }],
      "titleSecond": "Developer"
    }],
    "title": "Software Developer",
    "id" : 1234567890
  }
  </code></pre>
  
  <h1>Questions</h1>
  
  <p>1) How to remove the element with the given value of <code>titleSecond</code> and <code>id</code>?</p>
  
  <p>2) How to remove the element with the given value of <code>titleThird</code> and <code>id</code>?</p>
  
  <p>For first I tried the following implementation:</p>
  
  <pre><code>UpdateOperations&lt;First&gt; ops;
  Query&lt;First&gt; updateQuery = datastore.createQuery(First.class).filter("id", Long.parseLong(id.trim()));
  
  ops = datastore.createUpdateOperations(First.class).disableValidation().removeAll("secondClass.titleSecond", "Developer");
  datastore.update(updateQuery, ops);
  </code></pre>
  
  <p>but it's throwing mapping error:</p>
  
  <pre><code>Write failed with error code 16837 and error message 'cannot use the part (secondClass of secondClass.titleSecond) to traverse the element.
  </code></pre>
  
  <p>How can I perform the action for question 1 and 2? Any help would be appreciable. </p>
  
  <p>possibly linked question: <a href="https://stackoverflow.com/questions/9203141/in-morphia-how-can-i-update-one-embedded-object-inside-an-arraylist">In Morphia how can i update one embedded Object inside an ArrayList</a></p>