Skip to content

Commit

Permalink
Merge pull request #65 from UdL-EPS-SoftArch/crud-Shelter
Browse files Browse the repository at this point in the history
Fix find by name return Shelter not list
  • Loading branch information
rogargon authored Mar 8, 2024
2 parents 7941700 + b3aa1ae commit ae21573
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Shelter.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class Shelter extends UriEntity<Long> {
private Long id;

@NotBlank
@Column(unique = true)
private String name;

@NotBlank
Expand All @@ -37,12 +36,10 @@ public class Shelter extends UriEntity<Long> {
private String mobile;

@PastOrPresent
@GeneratedValue(strategy = GenerationType.AUTO)
@NotNull
private ZonedDateTime createdAt;

@PastOrPresent
@GeneratedValue(strategy = GenerationType.AUTO)
private ZonedDateTime updatedAt;

@NotNull
Expand All @@ -52,4 +49,11 @@ public class Shelter extends UriEntity<Long> {

@OneToOne
public Location locatedAt;

@PrePersist
public void prePersist() {
createdAt = ZonedDateTime.now();
updatedAt = ZonedDateTime.now();
isActive = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
@RepositoryRestResource
public interface ShelterRepository extends CrudRepository<Shelter, Long>, PagingAndSortingRepository<Shelter, Long> {
List<Shelter> findByName(@Param("name") String name);
List<Shelter> findByLocatedAt(@Param("location") Location location);
}

0 comments on commit ae21573

Please sign in to comment.