orphanRemoval JPA

1

How does orphanRemoval work?

Why when I put it in a list does not work ex:

    @OneToMany(mappedBy = "simulationMedia", cascade = CascadeType.ALL, orphanRemoval = true)
    @JsonIgnore
    private List<SimulationChemicalMedia> simulationChemicalMedias = new ArrayList<SimulationChemicalMedia>();
    
asked by anonymous 05.10.2015 / 22:19

1 answer

5

OrphanRemoval is present in most entity relationship annotations, and is used to define how a removal action assigned to an object will impact related objects.

OrphanRemoval marks "daughter" entities to be deleted when it has no other link to a parent entity, for example, when you have a car on a list of cars related to a dealership. If the concessionaire is excluded, if the car has no link with other concessionaires it will be deleted as well.

    
05.10.2015 / 22:40