diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java index 9ae162cc..4f2d28be 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java @@ -1,8 +1,6 @@ package cat.udl.eps.softarch.demo.domain; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; +import jakarta.persistence.*; import lombok.Data; import lombok.EqualsAndHashCode; @@ -22,4 +20,10 @@ public class Pet extends UriEntity { String age; String description; String breed; + + + @ManyToOne + public Shelter isIn; + @ManyToMany + public User[] favouritedBy; } diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java new file mode 100644 index 00000000..12af9121 --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/PetRepository.java @@ -0,0 +1,15 @@ +package cat.udl.eps.softarch.demo.repository; + +import cat.udl.eps.softarch.demo.domain.Pet; +import cat.udl.eps.softarch.demo.domain.User; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +public interface PetRepository extends CrudRepository, PagingAndSortingRepository { + List findBySize(@Param("size") String size); + //List findByShelter(@Param("Shelter") Shelter shelter); + +}