diff options
Diffstat (limited to 'Year_3/TSDWL/SPRING')
-rw-r--r-- | Year_3/TSDWL/SPRING/petshop/src/main/java/it/dmi/tsdw/petshop/Race.java | 1 | ||||
-rw-r--r-- | Year_3/TSDWL/SPRING/petshop/src/main/java/it/dmi/tsdw/petshop/repositories/PetRepository.java | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/Year_3/TSDWL/SPRING/petshop/src/main/java/it/dmi/tsdw/petshop/Race.java b/Year_3/TSDWL/SPRING/petshop/src/main/java/it/dmi/tsdw/petshop/Race.java index 4f08fe9..764eda6 100644 --- a/Year_3/TSDWL/SPRING/petshop/src/main/java/it/dmi/tsdw/petshop/Race.java +++ b/Year_3/TSDWL/SPRING/petshop/src/main/java/it/dmi/tsdw/petshop/Race.java @@ -6,6 +6,7 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.persistence.OneToMany; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; diff --git a/Year_3/TSDWL/SPRING/petshop/src/main/java/it/dmi/tsdw/petshop/repositories/PetRepository.java b/Year_3/TSDWL/SPRING/petshop/src/main/java/it/dmi/tsdw/petshop/repositories/PetRepository.java index 145e47e..d2ca7c9 100644 --- a/Year_3/TSDWL/SPRING/petshop/src/main/java/it/dmi/tsdw/petshop/repositories/PetRepository.java +++ b/Year_3/TSDWL/SPRING/petshop/src/main/java/it/dmi/tsdw/petshop/repositories/PetRepository.java @@ -1,6 +1,7 @@ package it.dmi.tsdw.petshop.repositories; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import it.dmi.tsdw.petshop.Pet; @@ -8,7 +9,9 @@ import it.dmi.tsdw.petshop.Race; @Repository public interface PetRepository extends JpaRepository<Pet, Long>{ - public Race findByRaceId(Long race_id); + @Query(value = "SELECT p FROM Pet p WHERE race_id = ?1") + public Race searchRace(Long race_id); + public Race findByRaceName(String name); } |