2
public class PrimeiroNivel {
@OneToMany(mappedBy="primeiroNivel", orphanRemoval=true)
private List<SegundoNivel> niveisSecundarios;
}
public class SegundoNivel {
@JoinColumn(name="primeirNivel")
@ManyToOne
private PrimeiroNivel primeiroNivel;
@JoinColumn(name="outraClasse")
@ManyToOne(cascade={CascadeType.ALL})
private OutraClasse outraClasse;
}
public class OutraClasse {
@OneToMany(mappedBy="outraClasse")
private List<SegundoNivel> segundosNiveis;
}
Considering the above classes and annotations:
instanciaDePrimeiroNivel.setNiveisSecundarios(null);
Does anyone know why the line above excludes the secondary levels that were present in the instantiation listDePrimeiroNivel (expected orphanRemoval behavior), but does not exclude the instances of Outraclasse associated in those excluded levels (which are marked for cascade exclusion)?
Cascadetype.REMOVE does not work if you do not use entityManager.remove(Object)?
Is there any alternative solution to resolve this situation?