Merge branch '43-delete-cascade-in-switch' into 'dev'
delete cascade no more in switch Closes #43 See merge request sa4-2020/the-sanmarinoes/backend!55
This commit is contained in:
commit
bbfb9f8fcb
1 changed files with 8 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue