diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java index 55cd6d47..6f392543 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Client.java @@ -1,21 +1,30 @@ package cat.udl.eps.softarch.demo.domain; -import jakarta.persistence.ElementCollection; -import jakarta.persistence.Entity; +import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.AuthorityUtils; import java.util.Collection; +import java.util.Set; @EqualsAndHashCode(callSuper = true) @Entity @Data public class Client extends User { + @ManyToMany + @JoinTable( + name = "client_shelter", + joinColumns = @JoinColumn(name = "client_id"), + inverseJoinColumns = @JoinColumn(name = "shelter_id") + ) + private Set shelters; + @Override @ElementCollection public Collection getAuthorities(){ return AuthorityUtils.commaSeparatedStringToAuthorityList("ROLE_CLIENT"); } } +