[6e7b472] | 1 | package com.wediscussmovies.project.model;
|
---|
| 2 |
|
---|
| 3 | import javax.persistence.*;
|
---|
| 4 | import java.sql.Date;
|
---|
[2d57cad] | 5 | import java.util.Collection;
|
---|
| 6 | import java.util.Objects;
|
---|
[6e7b472] | 7 |
|
---|
| 8 | @Entity
|
---|
[2d57cad] | 9 | @Table(name = "discussions", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
|
---|
[6e7b472] | 10 | public class Discussion {
|
---|
[2d57cad] | 11 | @GeneratedValue(strategy = GenerationType.IDENTITY)
|
---|
[6e7b472] | 12 | @Id
|
---|
[2d57cad] | 13 | @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 String text;
|
---|
| 21 | @Basic
|
---|
| 22 | @Column(name = "title")
|
---|
| 23 | private String title;
|
---|
| 24 | @Basic
|
---|
| 25 | @Column(name = "date")
|
---|
| 26 | private Date date;
|
---|
| 27 | @Basic
|
---|
| 28 | @Column(name = "user_id")
|
---|
| 29 | private int userId;
|
---|
| 30 | @Basic
|
---|
[6e7b472] | 31 | @Column(name = "movie_id")
|
---|
[2d57cad] | 32 | private Integer movieId;
|
---|
| 33 | @Basic
|
---|
[6e7b472] | 34 | @Column(name = "person_id")
|
---|
[2d57cad] | 35 | private Integer personId;
|
---|
[6e7b472] | 36 |
|
---|
| 37 | @ManyToOne
|
---|
[2d57cad] | 38 | @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false,insertable = false, updatable = false)
|
---|
| 39 | private User usersByUserId;
|
---|
| 40 | @ManyToOne
|
---|
| 41 | @JoinColumn(name = "movie_id", referencedColumnName = "movie_id",insertable = false, updatable = false)
|
---|
| 42 | private Movie moviesByMovieId;
|
---|
| 43 | @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;
|
---|
[6e7b472] | 48 |
|
---|
[2d57cad] | 49 | public int getDiscussionId() {
|
---|
| 50 | return discussionId;
|
---|
| 51 | }
|
---|
[6e7b472] | 52 |
|
---|
[2d57cad] | 53 | public void setDiscussionId(int discussionId) {
|
---|
| 54 | this.discussionId = discussionId;
|
---|
| 55 | }
|
---|
[6e7b472] | 56 |
|
---|
[2d57cad] | 57 | public String getType() {
|
---|
| 58 | return type;
|
---|
| 59 | }
|
---|
[6e7b472] | 60 |
|
---|
[2d57cad] | 61 | public void setType(String type) {
|
---|
| 62 | this.type = type;
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | public String getText() {
|
---|
| 66 | return text;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | public void setText(String text) {
|
---|
| 70 | this.text = text;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | public String getTitle() {
|
---|
| 74 | return title;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | public void setTitle(String title) {
|
---|
| 78 | this.title = title;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | public Date getDate() {
|
---|
| 82 | return date;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | public void setDate(Date date) {
|
---|
| 86 | this.date = date;
|
---|
| 87 | }
|
---|
[6e7b472] | 88 |
|
---|
[2d57cad] | 89 | public int getUserId() {
|
---|
| 90 | return userId;
|
---|
| 91 | }
|
---|
[6e7b472] | 92 |
|
---|
[2d57cad] | 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;
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | public Discussion() {
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 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 | }
|
---|
| 189 | }
|
---|