diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Room.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Room.java index fd11d1c..34f3824 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Room.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Room.java @@ -3,6 +3,8 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import ch.usi.inf.sa4.sanmarinoes.smarthut.config.GsonExclude; import com.google.gson.annotations.SerializedName; import io.swagger.annotations.ApiModelProperty; +import java.util.HashSet; +import java.util.Set; import javax.persistence.*; import javax.validation.constraints.NotNull; @@ -133,6 +135,10 @@ public class Room { @GsonExclude private User user; + @OneToMany(mappedBy = "room", orphanRemoval = true) + @GsonExclude + private Set devices = new HashSet<>(); + /** * User that owns the house this room is in as a foreign key id. To use when updating and * inserting from a REST call. @@ -186,6 +192,10 @@ public class Room { this.image = image; } + public Set getDevices() { + return devices; + } + @Override public String toString() { return "Room{" + "id=" + id + ", name='" + name + "\'}";