Ignore:
Timestamp:
01/16/22 20:22:55 (3 years ago)
Author:
Test <matonikolov77@…>
Branches:
main
Children:
3ded84d
Parents:
2d57cad (diff), 7bc8942 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Resolving models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/wediscussmovies/project/model/Discussion.java

    r2d57cad r7fafead  
    11package com.wediscussmovies.project.model;
     2
     3import com.wediscussmovies.project.model.enumerations.DiscussionType;
     4import lombok.Data;
    25
    36import javax.persistence.*;
    47import java.sql.Date;
    58import java.util.Collection;
     9import java.util.List;
    610import java.util.Objects;
    711
     12@Data
    813@Entity
    914@Table(name = "discussions", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    1015public class Discussion {
     16
    1117    @GeneratedValue(strategy = GenerationType.IDENTITY)
    1218    @Id
    1319    @Column(name = "discussion_id")
    14     private int discussionId;
    15     @Basic
    16     @Column(name = "type")
    17     private String type;
    18     @Basic
    19     @Column(name = "text")
     20    private Long id;
     21
     22    @Enumerated
     23    private DiscussionType type;
     24
    2025    private String text;
    21     @Basic
    22     @Column(name = "title")
     26
    2327    private String title;
    24     @Basic
    25     @Column(name = "date")
     28
    2629    private Date date;
    27     @Basic
    28     @Column(name = "user_id")
    29     private int userId;
    30     @Basic
    31     @Column(name = "movie_id")
    32     private Integer movieId;
    33     @Basic
    34     @Column(name = "person_id")
    35     private Integer personId;
     30
     31
     32
     33
    3634
    3735    @ManyToOne
    38     @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false,insertable = false, updatable = false)
    39     private User usersByUserId;
     36    @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false)
     37    private User user;
     38
    4039    @ManyToOne
    41     @JoinColumn(name = "movie_id", referencedColumnName = "movie_id",insertable = false, updatable = false)
    42     private Movie moviesByMovieId;
     40    @JoinColumn(name = "movie_id", referencedColumnName = "movie_id")
     41    private Movie movie;
     42
    4343    @ManyToOne
    44     @JoinColumn(name = "person_id", referencedColumnName = "person_id",insertable = false, updatable = false)
    45     private Person personsByPersonId;
    46     @OneToMany(mappedBy = "discussionsByDiscussionId")
    47     private Collection<Reply> repliesByDiscussionId;
     44    @JoinColumn(name = "person_id", referencedColumnName = "person_id")
     45    private Person person;
    4846
    49     public int getDiscussionId() {
    50         return discussionId;
    51     }
    5247
    53     public void setDiscussionId(int discussionId) {
    54         this.discussionId = discussionId;
    55     }
    5648
    57     public String getType() {
    58         return type;
    59     }
    6049
    61     public void setType(String type) {
     50
     51
     52    public Discussion(DiscussionType type, String text, String title, Date date, User user, Movie movie, Person person, List<Reply> replies) {
    6253        this.type = type;
    63     }
    64 
    65     public String getText() {
    66         return text;
    67     }
    68 
    69     public void setText(String text) {
    7054        this.text = text;
    71     }
    72 
    73     public String getTitle() {
    74         return title;
    75     }
    76 
    77     public void setTitle(String title) {
    7855        this.title = title;
    79     }
    80 
    81     public Date getDate() {
    82         return date;
    83     }
    84 
    85     public void setDate(Date date) {
    8656        this.date = date;
    87     }
    88 
    89     public int getUserId() {
    90         return userId;
    91     }
    92 
    93     public void setUserId(int userId) {
    94         this.userId = userId;
    95     }
    96 
    97     public Integer getMovieId() {
    98         return movieId;
    99     }
    100 
    101     public void setMovieId(Integer movieId) {
    102         this.movieId = movieId;
    103     }
    104 
    105     public Integer getPersonId() {
    106         return personId;
    107     }
    108 
    109     public void setPersonId(Integer personId) {
    110         this.personId = personId;
    111     }
    112 
    113     @Override
    114     public boolean equals(Object o) {
    115         if (this == o) return true;
    116         if (o == null || getClass() != o.getClass()) return false;
    117 
    118         Discussion that = (Discussion) o;
    119 
    120         if (discussionId != that.discussionId) return false;
    121         if (userId != that.userId) return false;
    122         if (!Objects.equals(type, that.type)) return false;
    123         if (!Objects.equals(text, that.text)) return false;
    124         if (!Objects.equals(title, that.title)) return false;
    125         if (!Objects.equals(date, that.date)) return false;
    126         if (!Objects.equals(movieId, that.movieId)) return false;
    127         if (!Objects.equals(personId, that.personId)) return false;
    128 
    129         return true;
    130     }
    131 
    132     @Override
    133     public int hashCode() {
    134         int result = discussionId;
    135         result = 31 * result + (type != null ? type.hashCode() : 0);
    136         result = 31 * result + (text != null ? text.hashCode() : 0);
    137         result = 31 * result + (title != null ? title.hashCode() : 0);
    138         result = 31 * result + (date != null ? date.hashCode() : 0);
    139         result = 31 * result + userId;
    140         result = 31 * result + (movieId != null ? movieId.hashCode() : 0);
    141         result = 31 * result + (personId != null ? personId.hashCode() : 0);
    142         return result;
    143     }
    144 
    145     public User getUsersByUserId() {
    146         return usersByUserId;
    147     }
    148 
    149     public void setUsersByUserId(User usersByUserId) {
    150         this.usersByUserId = usersByUserId;
    151     }
    152 
    153     public Movie getMoviesByMovieId() {
    154         return moviesByMovieId;
    155     }
    156 
    157     public void setMoviesByMovieId(Movie moviesByMovieId) {
    158         this.moviesByMovieId = moviesByMovieId;
    159     }
    160 
    161     public Person getPersonsByPersonId() {
    162         return personsByPersonId;
    163     }
    164 
    165     public void setPersonsByPersonId(Person personsByPersonId) {
    166         this.personsByPersonId = personsByPersonId;
    167     }
    168 
    169     public Collection<Reply> getRepliesByDiscussionId() {
    170         return repliesByDiscussionId;
    171     }
    172 
    173     public void setRepliesByDiscussionId(Collection<Reply> repliesByDiscussionId) {
    174         this.repliesByDiscussionId = repliesByDiscussionId;
     57        this.user = user;
     58        this.movie = movie;
     59        this.person = person;
    17560    }
    17661
     
    17863    }
    17964
    180     public Discussion(String type, String text, String title, Date date, int userId, Integer movieId, Integer personId) {
    181         this.type = type;
    182         this.text = text;
    183         this.title = title;
    184         this.date = date;
    185         this.userId = userId;
    186         this.movieId = movieId;
    187         this.personId = personId;
    188     }
     65
    18966}
Note: See TracChangeset for help on using the changeset viewer.