From 6e36d7d306e143050a0ca0a6cc22c1db571d2bb9 Mon Sep 17 00:00:00 2001 From: tommi27 Date: Fri, 17 Apr 2020 15:24:06 +0200 Subject: [PATCH] updated onetomany relationship --- .../sa4/sanmarinoes/smarthut/models/Invited.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Invited.java b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Invited.java index d56a55b..c389e18 100644 --- a/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Invited.java +++ b/src/main/java/ch/usi/inf/sa4/sanmarinoes/smarthut/models/Invited.java @@ -1,10 +1,7 @@ package ch.usi.inf.sa4.sanmarinoes.smarthut.models; import java.util.Set; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.OneToMany; +import javax.persistence.*; import javax.validation.constraints.NotNull; /** Represents a recursive invitation relationship between two users. */ @@ -12,11 +9,13 @@ import javax.validation.constraints.NotNull; public class Invited { /** A host user who can invite guests to their smart house */ - @OneToMany private Set host; + @OneToMany(mappedBy = "host") + private Set host; /** Guests that have been invited to the host's house */ - @OneToMany(mappedBy = "host", orphanRemoval = true) - private Set guest; + @ManyToOne + @JoinColumn(name = "guests") + private User guest; /** Host ID */ @Id