delete cascade no more
This commit is contained in:
parent
b9320ea078
commit
c17b6df3b5
1 changed files with 8 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue