delete cascade in room

This commit is contained in:
omenem 2020-03-24 15:58:01 +01:00
parent bbfb9f8fcb
commit 08c4ef49a7

View file

@ -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<Device> 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<Device> getDevices() {
return devices;
}
@Override
public String toString() {
return "Room{" + "id=" + id + ", name='" + name + "\'}";