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:
Matteo Omenetti 2020-03-24 16:03:33 +01:00
commit bcade19f52

View file

@ -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 + "\'}";