Ignore:
Timestamp:
03/08/23 17:01:43 (16 months ago)
Author:
SazdovaEkaterina <sazdovaekaterina@…>
Branches:
main
Children:
d1fe9c2
Parents:
8b7dd7f
Message:

fix many to one relations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Prototype Application/Paw5/src/main/java/finki/paw5/model/entities/Post.java

    r8b7dd7f rfdd7961  
    33import jakarta.persistence.*;
    44import lombok.Data;
     5import lombok.RequiredArgsConstructor;
    56
    67import java.time.LocalDate;
     
    89@Data
    910@Entity
     11@RequiredArgsConstructor
    1012@Table(name = "post")
    1113public class Post {
     
    2224    private String thumbnailUrl;
    2325
    24     @Column(name="id_pet", nullable = false)
    25     private Integer petId;
     26    @ManyToOne
     27    @JoinColumn(name="id_pet", nullable = false)
     28    private Pet pet;
    2629
    27     @Column(name="id_surendee")
    28     private Integer surendeeId;
     30    @ManyToOne
     31    @JoinColumn(name="id_surendee")
     32    private Surendee surendeePoster;
    2933
    30     @Column(name="id_employee")
    31     private Integer employeeId;
     34    @ManyToOne
     35    @JoinColumn(name="id_employee")
     36    private Employee employeePoster;
    3237
    33     public Post(LocalDate dateCreated, String thumbnailUrl, Integer petId, Integer surendeeId, Integer employeeId) {
     38    public Post(LocalDate dateCreated, String thumbnailUrl,
     39                Pet pet, Surendee surendeePoster, Employee employeePoster) {
    3440        this.dateCreated = dateCreated;
    3541        this.thumbnailUrl = thumbnailUrl;
    36         this.petId = petId;
    37         this.surendeeId = surendeeId;
    38         this.employeeId = employeeId;
    39     }
    40 
    41     public Post() {
     42        this.pet = pet;
     43        this.surendeePoster = surendeePoster;
     44        this.employeePoster = employeePoster;
    4245    }
    4346}
Note: See TracChangeset for help on using the changeset viewer.