title: child not detach from parent
body: <p>My document entity class is</p>
  
  <pre><code>    @Entity
      @Table(name="Document_Directory")
      public class DocumentDirectoryEntity{
  
      private int id;
      private String name;
      private DocumentDirectoryEntity parentDirectory;
      private List&lt;DocumentDirectoryEntity&gt; childDirectoryList;
  
      @Id
      @GeneratedValue(strategy=GenerationType.IDENTITY)
      public int getId() {
          return id;
      }
      public void setId(int id) {
          this.id = id;
      }
  
      @Column(name="name", length=250, nullable= false)
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
  
      @ManyToOne(fetch=FetchType.LAZY)
      @JoinColumn(name="parent_dir_id")
      public DocumentDirectoryEntity getParentDirectory() {
          return parentDirectory;
      }
      public void setParentDirectory(DocumentDirectoryEntity parentDirectory) {
          this.parentDirectory = parentDirectory;
      }
  
      @OneToMany(mappedBy="parentDirectory", cascade=CascadeType.ALL, fetch=FetchType.LAZY, orphanRemoval=true)
      public List&lt;DocumentDirectoryEntity&gt; getChildDirectoryList() {
          return childDirectoryList;
      }
      public void setChildDirectoryList(List&lt;DocumentDirectoryEntity&gt; childDirectoryList) {
          this.childDirectoryList = childDirectoryList;
      }
  }
  </code></pre>
  
  <p>I want delete a document but before delete, i want to change its child's parent. But I am not able to do it. code is:-</p>
  
  <pre><code>DocumentDirectoryEntity documentDirectoryEntity = documentDirectoryDao.findById(1);
  DocumentDirectoryEntity documentDirectoryEntity1 = documentDirectoryDao.findById(2);
  List&lt;DocumentDirectoryEntity&gt; childDirectoryList = documentDirectoryEntity.getChildDirectoryList();
  DocumentDirectoryEntity childDirectory = childDirectoryList.get(0);
  childDirectory.setParentDirectory(documentDirectoryEntity1);
  documentDirectoryDao.update(childDirectory);
  documentDirectoryDao.delete(documentDirectoryEntity);
  </code></pre>
  
  <p>when i delete object documentDirectoryEntity then childDirectory row is also removed.</p>