Skip to content

Commit

Permalink
Implemented shelter relations and repository
Browse files Browse the repository at this point in the history
  • Loading branch information
LordDangerous committed Mar 7, 2024
1 parent 8aebd15 commit 71f7841
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/main/java/cat/udl/eps/softarch/demo/domain/Shelter.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package cat.udl.eps.softarch.demo.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import jakarta.persistence.Id;
import com.fasterxml.jackson.annotation.JsonIdentityReference;
import jakarta.persistence.*;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jdk.jfr.BooleanFlag;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import java.time.LocalDateTime;

Expand All @@ -19,6 +17,21 @@
@EqualsAndHashCode(callSuper = false)
public class Shelter extends UriEntity<Long> {

@ManyToOne
@NotNull
@JsonIdentityReference(alwaysAsId = true)
private User user;

@ManyToOne
@NotNull
@JsonIdentityReference(alwaysAsId = true)
private Pet pet;

@OneToOne
@NotNull
@JsonIdentityReference(alwaysAsId = true)
private ShelterCertificate shelterCertificate;

@Id
private Long id;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cat.udl.eps.softarch.demo.repository;

import cat.udl.eps.softarch.demo.domain.Shelter;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.PagingAndSortingRepository;

public interface ShelterRepository extends CrudRepository<Shelter, String>, PagingAndSortingRepository<Shelter, String> {
Shelter findName(String name);
}

0 comments on commit 71f7841

Please sign in to comment.