delete cascade no more

This commit is contained in:
omenem 2020-03-23 17:53:22 +01:00
parent b9320ea078
commit c17b6df3b5

View file

@ -6,6 +6,7 @@ import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.PreRemove;
/** Represents a generic dimmer input device */
@Entity
@ -32,4 +33,11 @@ public abstract class Dimmer extends InputDevice {
public void addDimmableLight(DimmableLight dimmableLight) {
lights.add(dimmableLight);
}
@PreRemove
private void removeLightsFromDimmer() {
for (DimmableLight dl : getOutputs()) {
dl.setDimmerId(null);
}
}
}