Skip to content

Commit

Permalink
Merge pull request #93 from gfa-cc-after/SCRUM-94
Browse files Browse the repository at this point in the history
Scrum 94
  • Loading branch information
ramesz6 authored Aug 31, 2024
2 parents 5703a56 + 4a39ae7 commit b81d0fb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.greenfoxacademy.backend.models;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import java.util.Date;
import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -34,4 +37,8 @@ public class Pet {
private Date petBirthDate;
private Date lastCheckUp;
private Date nextCheckUp;
}

@ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "petOwner_Id")
private User petOwner;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.greenfoxacademy.backend.models;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
Expand Down Expand Up @@ -38,6 +42,9 @@ public class User implements UserDetails {
private String password;
private UUID verificationId;

@OneToMany(mappedBy = "petOwner", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
private List<Pet> pets = new ArrayList<>();

@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return List.of(new SimpleGrantedAuthority("ROLE_USER"));
Expand Down

0 comments on commit b81d0fb

Please sign in to comment.