delete cascade no more in switch

This commit is contained in:
omenem 2020-03-23 18:31:46 +01:00
parent 9ed2c66b54
commit f368084464

View File

@ -5,6 +5,7 @@ import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.PreRemove;
/** A switch input device */
@Entity
@ -51,4 +52,11 @@ public class Switch extends InputDevice {
public Set<Switchable> getOutputs() {
return switchables;
}
@PreRemove
private void removeSwitchable() {
for (Switchable s : getOutputs()) {
s.setSwitchId(null);
}
}
}