title: How to delete Child or Parent objects from Relationship?
body: <p>I did a small application with more relationships. Now I want to delete details of my table how can I delete I don't get any Idea to delete.</p>
  <p>Relationships are like below:</p>
  <blockquote>
  <p>PanCard--&gt;Employee  (Ono To One)</p>
  <p>Employee--&gt;ProjectManger (bi-directional many-to-one association to Employee)</p>
  <p>Projects --&gt;ProjectManager(bi-directional many-to-one association to Projects)</p>
  </blockquote>
  <p>Now I want delete the data of one by one table data</p>
  <p>Below is my POJO classes Code:</p>
  <h2>PanCard.java</h2>
  <pre><code>  @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name=&quot;id&quot;)
    private int id;
    @Column(name=&quot;pName&quot;)
    private String pName;
    @Column(name=&quot;pNumber&quot;)
    private int pNumber;    
    @OneToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER)
    @JoinColumn(name=&quot;EId&quot;)
    private Employee employee;
  </code></pre>
  <h2>Employee.java</h2>
  <pre><code>@Id
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  @Column(name = &quot;id&quot;)
  private int id;
  @Column(name = &quot;empFirstName&quot;)
  private String empFirstName;
  @Column(name = &quot;empLastName&quot;)
  private String empLastName;
  @Column(name = &quot;empDepartment&quot;)
  private String empDepartment;   
  @ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
  @JoinColumn(name=&quot;pmId&quot;)      
  private ProjectManager projectManager;
  </code></pre>
  <h2>ProjectManager.java</h2>
  <pre><code>@Id
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  private int id;
  
  private String department;
  
  private String managerFirstName;
  
  private String managerLastName;
  
  //bi-directional many-to-one association to Myemployee
  
  @OneToMany(mappedBy=&quot;projectManager&quot;,cascade = CascadeType.ALL)
  private List&lt;Employee&gt; employee;
  
  @OneToMany(mappedBy=&quot;projectManager&quot;,cascade = CascadeType.ALL)
  private List&lt;Projects&gt; projects;
  </code></pre>
  <h2>Projects.java</h2>
  <pre><code> @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name=&quot;id&quot;)
    private int id;
    @Column(name=&quot;projectName&quot;)
    private String projectName;
    @Column(name=&quot;projectDesc&quot;)
    private String projectDesc;     
    @ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
    @JoinColumn(name=&quot;pmId&quot;)    
    private ProjectManager projectManager;
  </code></pre>
  <p>Now I want delete the tables data: From which table I should start deletion.</p>
  <ul>
  <li>If I want to delete <code>Pancard</code> I should delete <code>ProjectManager</code> because <code>Employee</code> have FK.</li>
  <li>If I want to delete <code>ProjectManager</code> it should delete the <code>Employee</code> and <code>Projects</code> but <code>Employee</code> have relationship with <code>PanCard</code> So it's not deleting.</li>
  <li>If I want to delete <code>Projects</code> it should delete <code>ProjectManager</code> but <code>ProjectManger</code> have relation ship with <code>Employee</code> So it's not deleting.</li>
  </ul>
  <p>So from where I have to start deletion and how can I delete the I don't know.</p>