diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/Shelter.java b/src/main/java/cat/udl/eps/softarch/demo/domain/Shelter.java index 7fdaaf46..172379c9 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/Shelter.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/Shelter.java @@ -24,7 +24,6 @@ public class Shelter extends UriEntity { private Long id; @NotBlank - @Column(unique = true) private String name; @NotBlank @@ -37,12 +36,10 @@ public class Shelter extends UriEntity { private String mobile; @PastOrPresent - @GeneratedValue(strategy = GenerationType.AUTO) @NotNull private ZonedDateTime createdAt; @PastOrPresent - @GeneratedValue(strategy = GenerationType.AUTO) private ZonedDateTime updatedAt; @NotNull @@ -52,4 +49,11 @@ public class Shelter extends UriEntity { @OneToOne public Location locatedAt; + + @PrePersist + public void prePersist() { + createdAt = ZonedDateTime.now(); + updatedAt = ZonedDateTime.now(); + isActive = false; + } } \ No newline at end of file diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterRepository.java index 631219ae..04b828d8 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterRepository.java +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterRepository.java @@ -13,4 +13,5 @@ @RepositoryRestResource public interface ShelterRepository extends CrudRepository, PagingAndSortingRepository { List findByName(@Param("name") String name); + List findByLocatedAt(@Param("location") Location location); } \ No newline at end of file