diff options
author | Santo Cariotti <santo@dcariotti.me> | 2023-01-07 18:51:03 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2023-01-07 18:51:03 +0100 |
commit | 9240342b366db9999f11659a1f1c396ba418ad78 (patch) | |
tree | f34e9259cbb6f8d4bcdea234e4b2c927950411cc /Year_3/TSDWL/SPRING/petshop/src/main | |
parent | ba36beaec6d37d26b075d96e58aad73151d6d39e (diff) |
Adds
Diffstat (limited to 'Year_3/TSDWL/SPRING/petshop/src/main')
-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); } |