From c90f79af3a9529028cc48bc758bdd15cc6b9c0f4 Mon Sep 17 00:00:00 2001 From: Angel Baro Date: Thu, 29 Feb 2024 15:36:39 +0100 Subject: [PATCH 1/2] OneToOne relationship with Shelter --- src/main/java/cat/udl/eps/softarch/demo/domain/Location.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java index 4623fc2..d515f78 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Location.java @@ -12,6 +12,10 @@ @Entity @EqualsAndHashCode(callSuper = false) public class Location { + @OneToOne + @NotNull + @JsonIdentityReference(alwaysAsId = true) + private Shelter shelter; @Id @GeneratedValue(strategy = GenerationType.AUTO) From 525aab0777f732e1c72b368adf149aa4b2e904c5 Mon Sep 17 00:00:00 2001 From: Angel Baro Date: Wed, 6 Mar 2024 17:29:08 +0100 Subject: [PATCH 2/2] Added repository for Location class --- .../softarch/demo/repository/LocationRepository.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java new file mode 100644 index 0000000..ea42215 --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/LocationRepository.java @@ -0,0 +1,11 @@ +package cat.udl.eps.softarch.demo.repository; + +import cat.udl.eps.softarch.demo.domain.Location; +import cat.udl.eps.softarch.demo.domain.User; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface LocationRepository extends CrudRepository, PagingAndSortingRepository { + + +}