title: When I delete an entry from a table which has foreign keys to others, the corresponding records are not deleted as well
body: <p>I have a table (Entity) from which I delete some entries based on an ID from a different entity in Java.</p>
  
  <p>This table has foreign keys to other tables, let's say the fields are ID1 and ID2.
  When I delete with an HQL query the entry with ID, the ones with ID1 and ID2 are still there.
  Those entities which have ID1 and ID2 are joined with @ManyToOne(CascadeType.ALL), so I cannot use orphanRemoval = true..</p>
  
  <p>Does anyone have any idea what I should do ?</p>
  
  <p>The Entity class:</p>
  
  <pre><code>@ManyToOne(targetEntity = First.class, cascade = {CascadeType.ALL})
  @JoinColumn(name = "ID_LINE_HEADER")
  private First lineHeader;
  
  @ManyToOne(targetEntity = Second.class, cascade = {CascadeType.ALL})
  @JoinColumn(name = "ID_LINE_CONTENT")
  private Second lineContent;
  </code></pre>
  
  <p>The query:</p>
  
  <pre><code>        @Query(value = "" +
          "Delete " +
          "from " +
          "   Entity u " +
          "where " +
          "  u.JobExecutionId = :JobExecution ")
  </code></pre>