Skip to content

Commit

Permalink
Merge pull request #26 from UdL-EPS-SoftArch/crud-Pet
Browse files Browse the repository at this point in the history
Pet - relation+repository
  • Loading branch information
elskater98 authored Feb 29, 2024
2 parents f5d61a9 + 0b3c6ea commit 3ed0f07
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Pet.java
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -22,4 +20,10 @@ public class Pet extends UriEntity<Long> {
String age;
String description;
String breed;


@ManyToOne
public Shelter isIn;
@ManyToMany
public User[] favouritedBy;
}
Original file line number Diff line number Diff line change
@@ -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<Pet, Long>, PagingAndSortingRepository<Pet, Long> {
List<User> findBySize(@Param("size") String size);
//List<Shelter> findByShelter(@Param("Shelter") Shelter shelter);

}

0 comments on commit 3ed0f07

Please sign in to comment.