Merge branch '44-delete-cascade-when-room-is-deleted' into 'dev'
delete cascade in room Closes #44 See merge request sa4-2020/the-sanmarinoes/backend!56
This commit is contained in:
commit
bcade19f52
1 changed files with 10 additions and 0 deletions
|
@ -3,6 +3,8 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude;
|
import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
@ -133,6 +135,10 @@ public class Room {
|
||||||
@GsonExclude
|
@GsonExclude
|
||||||
private User user;
|
private User user;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "room", orphanRemoval = true)
|
||||||
|
@GsonExclude
|
||||||
|
private Set<Device> devices = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User that owns the house this room is in as a foreign key id. To use when updating and
|
* User that owns the house this room is in as a foreign key id. To use when updating and
|
||||||
* inserting from a REST call.
|
* inserting from a REST call.
|
||||||
|
@ -186,6 +192,10 @@ public class Room {
|
||||||
this.image = image;
|
this.image = image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<Device> getDevices() {
|
||||||
|
return devices;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Room{" + "id=" + id + ", name='" + name + "\'}";
|
return "Room{" + "id=" + id + ", name='" + name + "\'}";
|
||||||
|
|
Loading…
Reference in a new issue