I have a table (Entity) from which I delete some entries based on an ID from a different entity in Java.
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..
Does anyone have any idea what I should do ?
The Entity class:
@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;
The query:
@Query(value = "" +
"Delete " +
"from " +
" Entity u " +
"where " +
" u.JobExecutionId = :JobExecution ")