diff --git a/EntitiesModel.puml b/EntitiesModel.puml index 08d033d7..876180c4 100644 --- a/EntitiesModel.puml +++ b/EntitiesModel.puml @@ -90,6 +90,11 @@ class MedicalRecord { date : Date } +class FavouritedPets { + id : Long + petId : Long +} + Pet "1" -- "*" MedicalRecord : has > @@ -104,4 +109,5 @@ Client "*" -> "*" Shelter : donate > Adoption "*" -> "1" Pet :adopted > Adoption "*" -> "1" User :adopt < ShelterVolunteer "1.*" -> "*" Shelter : works > +User "1" -> "*" FavouritedPets : hasFavourited > @enduml \ No newline at end of file diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/FavouritedPets.java b/src/main/java/cat/udl/eps/softarch/demo/domain/FavouritedPets.java new file mode 100644 index 00000000..7fa9eb4f --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/FavouritedPets.java @@ -0,0 +1,18 @@ +package cat.udl.eps.softarch.demo.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Entity +@Data +public class FavouritedPets extends UriEntity { + @Id + @NotNull + Long id; + + Long petId; +} diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/User.java b/src/main/java/cat/udl/eps/softarch/demo/domain/User.java index a7e9fa07..43a9b200 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/User.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/User.java @@ -1,12 +1,10 @@ package cat.udl.eps.softarch.demo.domain; import com.fasterxml.jackson.annotation.JsonProperty; - +import com.fasterxml.jackson.annotation.JsonValue; import jakarta.persistence.*; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; - -import com.fasterxml.jackson.annotation.JsonValue; import lombok.Data; import lombok.EqualsAndHashCode; import org.hibernate.validator.constraints.Length; @@ -77,7 +75,7 @@ public boolean isEnabled() { return true; } - @ManyToMany - public List favouritedPets; + @OneToMany(fetch = FetchType.EAGER) + public List favouritedPets; }