Ignore:
Timestamp:
01/16/22 17:12:01 (3 years ago)
Author:
Test <matonikolov77@…>
Branches:
main
Children:
7fafead
Parents:
839f96a
Message:

Initial model part

File:
1 edited

Legend:

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

    r839f96a r2d57cad  
    44import java.sql.Date;
    55
    6 @Entity(name="replies")
     6@Entity
     7@Table(name = "replies", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
     8@IdClass(RepliesEntityPK.class)
    79public class Reply {
    810    @Id
    9     @GeneratedValue
     11    @Column(name = "discussion_id",insertable = false, updatable = false)
     12    private int discussionId;
     13    @GeneratedValue(strategy = GenerationType.IDENTITY)
     14    @Id
    1015    @Column(name = "reply_id")
    11     private int reply_id;
     16    private int replyId;
     17    @Basic
     18    @Column(name = "text")
     19    private String text;
     20    @Basic
     21    @Column(name = "date")
     22    private Date date;
     23    @Basic
     24    @Column(name = "user_id")
     25    private int userId;
     26    @ManyToOne
     27    @JoinColumn(name = "discussion_id", referencedColumnName = "discussion_id", nullable = false,insertable = false, updatable = false)
     28    private Discussion discussionsByDiscussionId;
     29    @ManyToOne
     30    @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false,insertable = false, updatable = false)
     31    private User usersByUserId;
    1232
    13     @ManyToOne
    14     @Column(name = "discussion_id")
    15     private Discussion discussion;
     33    public int getDiscussionId() {
     34        return discussionId;
     35    }
    1636
    17     @ManyToOne
    18     @Column(name = "user_id")
    19     private User user;
     37    public void setDiscussionId(int discussionId) {
     38        this.discussionId = discussionId;
     39    }
    2040
    21     @Column(name = "date", nullable = false)
    22     private Date date;
     41    public int getReplyId() {
     42        return replyId;
     43    }
    2344
    24     @Column(name= "text", length = 1000, nullable = false)
    25     private String text;
     45    public void setReplyId(int replyId) {
     46        this.replyId = replyId;
     47    }
     48
     49    public String getText() {
     50        return text;
     51    }
     52
     53    public void setText(String text) {
     54        this.text = text;
     55    }
     56
     57    public Date getDate() {
     58        return date;
     59    }
     60
     61    public void setDate(Date date) {
     62        this.date = date;
     63    }
     64
     65    public int getUserId() {
     66        return userId;
     67    }
     68
     69    public void setUserId(int userId) {
     70        this.userId = userId;
     71    }
     72
     73    @Override
     74    public boolean equals(Object o) {
     75        if (this == o) return true;
     76        if (o == null || getClass() != o.getClass()) return false;
     77
     78        Reply that = (Reply) o;
     79
     80        if (discussionId != that.discussionId) return false;
     81        if (replyId != that.replyId) return false;
     82        if (userId != that.userId) return false;
     83        if (text != null ? !text.equals(that.text) : that.text != null) return false;
     84        if (date != null ? !date.equals(that.date) : that.date != null) return false;
     85
     86        return true;
     87    }
     88
     89    @Override
     90    public int hashCode() {
     91        int result = discussionId;
     92        result = 31 * result + replyId;
     93        result = 31 * result + (text != null ? text.hashCode() : 0);
     94        result = 31 * result + (date != null ? date.hashCode() : 0);
     95        result = 31 * result + userId;
     96        return result;
     97    }
     98
     99    public Discussion getDiscussionsByDiscussionId() {
     100        return discussionsByDiscussionId;
     101    }
     102
     103    public void setDiscussionsByDiscussionId(Discussion discussionsByDiscussionId) {
     104        this.discussionsByDiscussionId = discussionsByDiscussionId;
     105    }
     106
     107    public User getUsersByUserId() {
     108        return usersByUserId;
     109    }
     110
     111    public void setUsersByUserId(User usersByUserId) {
     112        this.usersByUserId = usersByUserId;
     113    }
    26114}
    27 
    28 
    29 /*
    30 
    31     create table replies(
    32         discussion_id integer,
    33         reply_id serial,
    34         text varchar(1000) not null,
    35         date date not null,
    36         user_id integer not null,
    37         constraint pk_replies primary key(discussion_id,reply_id),
    38         constraint fk_user_create_reply foreign key (user_id) references users(user_id)
    39         on delete cascade on update cascade,
    40         constraint fk_reply_discussion foreign key (discussion_id) references discussions(discussion_id)
    41         on delete cascade on update cascade
    42 
    43 
    44     );
    45  */
Note: See TracChangeset for help on using the changeset viewer.