Merge branch '40-on-delete-set-null-must-be-set-in-sql-schema' into 'dev'
delete cascade no more Closes #40 See merge request sa4-2020/the-sanmarinoes/backend!54
This commit is contained in:
commit
9ed2c66b54
1 changed files with 8 additions and 0 deletions
|
@ -6,6 +6,7 @@ import javax.persistence.Entity;
|
||||||
import javax.persistence.Inheritance;
|
import javax.persistence.Inheritance;
|
||||||
import javax.persistence.InheritanceType;
|
import javax.persistence.InheritanceType;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.PreRemove;
|
||||||
|
|
||||||
/** Represents a generic dimmer input device */
|
/** Represents a generic dimmer input device */
|
||||||
@Entity
|
@Entity
|
||||||
|
@ -32,4 +33,11 @@ public abstract class Dimmer extends InputDevice {
|
||||||
public void addDimmableLight(DimmableLight dimmableLight) {
|
public void addDimmableLight(DimmableLight dimmableLight) {
|
||||||
lights.add(dimmableLight);
|
lights.add(dimmableLight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PreRemove
|
||||||
|
private void removeLightsFromDimmer() {
|
||||||
|
for (DimmableLight dl : getOutputs()) {
|
||||||
|
dl.setDimmerId(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue