Changeset 2d57cad in Git for src/main/java/com


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

Initial model part

Location:
src/main/java/com/wediscussmovies/project/model
Files:
13 added
1 deleted
6 edited

Legend:

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

    r839f96a r2d57cad  
    33import javax.persistence.*;
    44import java.sql.Date;
    5 import java.util.List;
     5import java.util.Collection;
     6import java.util.Objects;
    67
    78@Entity
     9@Table(name = "discussions", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    810public class Discussion {
     11    @GeneratedValue(strategy = GenerationType.IDENTITY)
    912    @Id
    10     @GeneratedValue
    11     private int discussion_id;
     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
     31    @Column(name = "movie_id")
     32    private Integer movieId;
     33    @Basic
     34    @Column(name = "person_id")
     35    private Integer personId;
    1236
    1337    @ManyToOne
    14     @Column(name = "movie_id")
    15     private Movie movie;
     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;
    1648
    17     @ManyToOne()
    18     @Column(name = "person_id")
    19     private Person person;
     49    public int getDiscussionId() {
     50        return discussionId;
     51    }
    2052
    21     @ManyToOne
    22     @Column(name = "user_id")
    23     private User user;
     53    public void setDiscussionId(int discussionId) {
     54        this.discussionId = discussionId;
     55    }
    2456
    25     @Column(name = "text", length = 1000, nullable = false)
    26     private String text;
     57    public String getType() {
     58        return type;
     59    }
    2760
    28     @Column(name = "title", length = 1000, nullable = false)
    29     private String title;
     61    public void setType(String type) {
     62        this.type = type;
     63    }
    3064
    31     @Column(name = "date", nullable = false)
    32     private Date date;
     65    public String getText() {
     66        return text;
     67    }
    3368
    34     @OneToMany
    35     private List<Reply> replies;
     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    }
     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;
     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    }
    36189}
    37 
    38 
    39 /*
    40     create table discussions(
    41         discussion_id serial primary key,
    42         type char(1) not null,
    43         text varchar(1000) not null,
    44         title varchar(250) not null,
    45         date date not null,
    46         user_id integer not null,
    47         movie_id integer,
    48         person_id integer,
    49         constraint fk_user_created foreign key (user_id) references users(user_id)
    50         on delete cascade on update cascade,
    51         constraint ck_type_discussion check( (type = 'M' and movie_id notnull and person_id isnull)
    52         or (type='P' and person_id  notnull and movie_id isnull)),
    53         constraint fk_discussion_movie foreign key (movie_id) references movies(movie_id)
    54         on delete cascade on update cascade,
    55         constraint fk_discussion_person foreign key (person_id) references persons(person_id)
    56         on delete cascade on update cascade
    57     );
    58 
    59  */
  • src/main/java/com/wediscussmovies/project/model/Genre.java

    r839f96a r2d57cad  
    11package com.wediscussmovies.project.model;
    22
    3 import javax.persistence.Column;
    4 import javax.persistence.Entity;
    5 import javax.persistence.GeneratedValue;
    6 import javax.persistence.Id;
     3import javax.persistence.*;
     4import java.util.Collection;
    75
    8 @Entity(name="genres")
     6@Entity
     7@Table(name = "genres", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    98public class Genre {
     9    @GeneratedValue(strategy = GenerationType.IDENTITY)
    1010    @Id
    11     @GeneratedValue
    12     @Column(name="genre_id", nullable = false, unique = true)
    13     private int genre_id;
     11    @Column(name = "genre_id")
     12    private int genreId;
     13    @Basic
     14    @Column(name = "genre_type")
     15    private String genreType;
     16    @OneToMany(mappedBy = "genresByGenreId")
     17    private Collection<MovieGenresEntity> movieGenresByGenreId;
     18    @OneToMany(mappedBy = "genresByGenreId")
     19    private Collection<UserGenresEntity> userGenresByGenreId;
    1420
    15     @Column(name="genre_type", length = 100, nullable = false, unique = true)
    16     private String genre_type;
     21    public int getGenreId() {
     22        return genreId;
     23    }
     24
     25    public void setGenreId(int genreId) {
     26        this.genreId = genreId;
     27    }
     28
     29    public String getGenreType() {
     30        return genreType;
     31    }
     32
     33    public void setGenreType(String genreType) {
     34        this.genreType = genreType;
     35    }
     36
     37    @Override
     38    public boolean equals(Object o) {
     39        if (this == o) return true;
     40        if (o == null || getClass() != o.getClass()) return false;
     41
     42        Genre that = (Genre) o;
     43
     44        if (genreId != that.genreId) return false;
     45        if (genreType != null ? !genreType.equals(that.genreType) : that.genreType != null) return false;
     46
     47        return true;
     48    }
     49
     50    @Override
     51    public int hashCode() {
     52        int result = genreId;
     53        result = 31 * result + (genreType != null ? genreType.hashCode() : 0);
     54        return result;
     55    }
     56
     57    public Collection<MovieGenresEntity> getMovieGenresByGenreId() {
     58        return movieGenresByGenreId;
     59    }
     60
     61    public void setMovieGenresByGenreId(Collection<MovieGenresEntity> movieGenresByGenreId) {
     62        this.movieGenresByGenreId = movieGenresByGenreId;
     63    }
     64
     65    public Collection<UserGenresEntity> getUserGenresByGenreId() {
     66        return userGenresByGenreId;
     67    }
     68
     69    public void setUserGenresByGenreId(Collection<UserGenresEntity> userGenresByGenreId) {
     70        this.userGenresByGenreId = userGenresByGenreId;
     71    }
     72
     73    public Genre(String genreType) {
     74        this.genreType = genreType;
     75    }
     76
     77    public Genre() {
     78    }
    1779}
    18 
    19 /*
    20 
    21 create table genres(
    22     genre_id serial primary key,
    23     genre_type varchar(100) not null unique
    24 );
    25 
    26  */
  • src/main/java/com/wediscussmovies/project/model/Movie.java

    r839f96a r2d57cad  
    33import javax.persistence.*;
    44import java.sql.Date;
    5 import java.util.List;
     5import java.util.Collection;
     6import java.util.Objects;
    67
    7 @Entity(name="movies")
     8@Entity
     9@Table(name = "movies", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    810public class Movie {
     11    @GeneratedValue(strategy = GenerationType.IDENTITY)
    912    @Id
    10     @GeneratedValue
    11     @Column(name="movie_id", nullable = false)
    12     private int movie_id;
     13    @Column(name = "movie_id")
     14    private int movieId;
     15    @Basic
     16    @Column(name = "title")
     17    private String title;
     18    @Basic
     19    @Column(name = "description")
     20    private String description;
     21    @Basic
     22    @Column(name = "image_url")
     23    private String imageUrl;
     24    @Basic
     25    @Column(name = "airing_date")
     26    private Date airingDate;
     27    @Basic
     28    @Column(name = "imdb_rating")
     29    private Double imdbRating;
     30    @Basic
     31    @Column(name = "director_id")
     32    private Integer directorId;
     33    @OneToMany(mappedBy = "moviesByMovieId")
     34    private Collection<Discussion> discussionsByMovieId;
     35    @OneToMany(mappedBy = "moviesByMovieId")
     36    private Collection<MovieActorsEntity> movieActorsByMovieId;
     37    @OneToMany(mappedBy = "moviesByMovieId")
     38    private Collection<MovieGenresEntity> movieGenresByMovieId;
     39    @OneToMany(mappedBy = "moviesByMovieId")
     40    private Collection<MovieLikesEntity> movieLikesByMovieId;
     41    @OneToMany(mappedBy = "moviesByMovieId")
     42    private Collection<MovieRatesEntity> movieRatesByMovieId;
     43    @ManyToOne
     44    @JoinColumn(name = "director_id", referencedColumnName = "person_id",insertable = false, updatable = false)
     45    private Person personsByDirectorId;
    1346
    14     @Column(name="title", length = 150, unique = true, nullable = false)
    15     private String Title;
     47    public int getMovieId() {
     48        return movieId;
     49    }
    1650
    17     @Column(name="description", nullable = false, length = 1000)
    18     private String description;
     51    public void setMovieId(int movieId) {
     52        this.movieId = movieId;
     53    }
    1954
    20     @Column(name="image_url", length = 300, nullable = false)
    21     private String image_url;
     55    public String getTitle() {
     56        return title;
     57    }
    2258
    23     @Column(name="airing_date")
    24     private Date airing_date;
     59    public void setTitle(String title) {
     60        this.title = title;
     61    }
    2562
    26     @Column(name="imdb_rating")
    27     private float imdb_rating;
     63    public String getDescription() {
     64        return description;
     65    }
    2866
    29     @Column(name="director_id")
    30     @ManyToOne
    31     private Person director;
     67    public void setDescription(String description) {
     68        this.description = description;
     69    }
    3270
    33     @ManyToMany(mappedBy = "movie_actors")
    34     private List<Person> actors;
     71    public String getImageUrl() {
     72        return imageUrl;
     73    }
    3574
    36     @ManyToMany(mappedBy = "movie_genres")
    37     private List<Genre> genres;
     75    public void setImageUrl(String imageUrl) {
     76        this.imageUrl = imageUrl;
     77    }
     78
     79    public Date getAiringDate() {
     80        return airingDate;
     81    }
     82
     83    public void setAiringDate(Date airingDate) {
     84        this.airingDate = airingDate;
     85    }
     86
     87    public Double getImdbRating() {
     88        return imdbRating;
     89    }
     90
     91    public void setImdbRating(Double imdbRating) {
     92        this.imdbRating = imdbRating;
     93    }
     94
     95    public Integer getDirectorId() {
     96        return directorId;
     97    }
     98
     99    public void setDirectorId(Integer directorId) {
     100        this.directorId = directorId;
     101    }
     102
     103    @Override
     104    public boolean equals(Object o) {
     105        if (this == o) return true;
     106        if (o == null || getClass() != o.getClass()) return false;
     107
     108        Movie that = (Movie) o;
     109
     110        if (movieId != that.movieId) return false;
     111        if (!Objects.equals(title, that.title)) return false;
     112        if (!Objects.equals(description, that.description)) return false;
     113        if (!Objects.equals(imageUrl, that.imageUrl)) return false;
     114        if (!Objects.equals(airingDate, that.airingDate)) return false;
     115        if (!Objects.equals(imdbRating, that.imdbRating)) return false;
     116        if (!Objects.equals(directorId, that.directorId)) return false;
     117
     118        return true;
     119    }
     120
     121    public Movie(String title, String description, String imageUrl, Date airingDate, Double imdbRating, Integer directorId) {
     122        this.title = title;
     123        this.description = description;
     124        this.imageUrl = imageUrl;
     125        this.airingDate = airingDate;
     126        this.imdbRating = imdbRating;
     127        this.directorId = directorId;
     128    }
     129
     130    public Movie() {
     131    }
     132
     133    @Override
     134    public int hashCode() {
     135        int result = movieId;
     136        result = 31 * result + (title != null ? title.hashCode() : 0);
     137        result = 31 * result + (description != null ? description.hashCode() : 0);
     138        result = 31 * result + (imageUrl != null ? imageUrl.hashCode() : 0);
     139        result = 31 * result + (airingDate != null ? airingDate.hashCode() : 0);
     140        result = 31 * result + (imdbRating != null ? imdbRating.hashCode() : 0);
     141        result = 31 * result + (directorId != null ? directorId.hashCode() : 0);
     142        return result;
     143    }
     144
     145    public Collection<Discussion> getDiscussionsByMovieId() {
     146        return discussionsByMovieId;
     147    }
     148
     149    public void setDiscussionsByMovieId(Collection<Discussion> discussionsByMovieId) {
     150        this.discussionsByMovieId = discussionsByMovieId;
     151    }
     152
     153    public Collection<MovieActorsEntity> getMovieActorsByMovieId() {
     154        return movieActorsByMovieId;
     155    }
     156
     157    public void setMovieActorsByMovieId(Collection<MovieActorsEntity> movieActorsByMovieId) {
     158        this.movieActorsByMovieId = movieActorsByMovieId;
     159    }
     160
     161    public Collection<MovieGenresEntity> getMovieGenresByMovieId() {
     162        return movieGenresByMovieId;
     163    }
     164
     165    public void setMovieGenresByMovieId(Collection<MovieGenresEntity> movieGenresByMovieId) {
     166        this.movieGenresByMovieId = movieGenresByMovieId;
     167    }
     168
     169    public Collection<MovieLikesEntity> getMovieLikesByMovieId() {
     170        return movieLikesByMovieId;
     171    }
     172
     173    public void setMovieLikesByMovieId(Collection<MovieLikesEntity> movieLikesByMovieId) {
     174        this.movieLikesByMovieId = movieLikesByMovieId;
     175    }
     176
     177    public Collection<MovieRatesEntity> getMovieRatesByMovieId() {
     178        return movieRatesByMovieId;
     179    }
     180
     181    public void setMovieRatesByMovieId(Collection<MovieRatesEntity> movieRatesByMovieId) {
     182        this.movieRatesByMovieId = movieRatesByMovieId;
     183    }
     184
     185    public Person getPersonsByDirectorId() {
     186        return personsByDirectorId;
     187    }
     188
     189    public void setPersonsByDirectorId(Person personsByDirectorId) {
     190        this.personsByDirectorId = personsByDirectorId;
     191    }
    38192}
    39 
    40 
    41 /*
    42 
    43     create table movies(
    44         movie_id serial primary key,
    45         title varchar(150) not null unique,
    46         description varchar(1000) not null,
    47         image_url varchar(300) not null,
    48         airing_date date not null,
    49         imdb_rating float,
    50         director_id integer,
    51         constraint fk_movie_director foreign key (director_id) references persons(person_id)
    52         on delete cascade on update cascade,
    53         constraint ck_person_is_director check( check_constraint_person(director_id) = 'D')
    54     );
    55  */
  • src/main/java/com/wediscussmovies/project/model/Person.java

    r839f96a r2d57cad  
    33import javax.persistence.*;
    44import java.sql.Date;
    5 import java.util.List;
     5import java.util.Collection;
    66
    7 @Entity(name="persons")
     7@Entity
     8@Table(name = "persons", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    89public class Person {
     10    @GeneratedValue(strategy = GenerationType.IDENTITY)
    911    @Id
    10     @GeneratedValue
    11     private int person_id;
     12    @Column(name = "person_id")
     13    private int personId;
     14    @Basic
     15    @Column(name = "name")
     16    private String name;
     17    @Basic
     18    @Column(name = "surname")
     19    private String surname;
     20    @Basic
     21    @Column(name = "type")
     22    private String type;
     23    @Basic
     24    @Column(name = "date_of_birth")
     25    private Date dateOfBirth;
     26    @Basic
     27    @Column(name = "image_url")
     28    private String imageUrl;
     29    @Basic
     30    @Column(name = "description")
     31    private String description;
     32    @OneToMany(mappedBy = "personsByPersonId")
     33    private Collection<Discussion> discussionsByPersonId;
     34    @OneToMany(mappedBy = "personsByActorId")
     35    private Collection<MovieActorsEntity> movieActorsByPersonId;
     36    @OneToMany(mappedBy = "personsByDirectorId")
     37    private Collection<Movie> moviesByPersonId;
     38    @OneToMany(mappedBy = "personsByPersonId")
     39    private Collection<PersonRatesEntity> personRatesByPersonId;
    1240
    13     @Column(name="name", length=100, nullable=false, unique=false)
    14     private String name;
     41    public int getPersonId() {
     42        return personId;
     43    }
    1544
    16     @Column(name="surname", length=100, nullable=false, unique=false)
    17     private String surname;
     45    public void setPersonId(int personId) {
     46        this.personId = personId;
     47    }
    1848
    19     @Column(name="type", nullable = false)
    20     private PersonType personType;
     49    public String getName() {
     50        return name;
     51    }
    2152
    22     @Column(name="date_of_birth", nullable=false)
    23     private Date date_of_birth;
     53    public void setName(String name) {
     54        this.name = name;
     55    }
    2456
    25     @Column(name="image_url", length=300, nullable=false, unique=false)
    26     private String image_url;
     57    public String getSurname() {
     58        return surname;
     59    }
    2760
    28     @Column(name="description", length=300, nullable=false, unique=false)
    29     private String description;
     61    public void setSurname(String surname) {
     62        this.surname = surname;
     63    }
    3064
    31     @ManyToMany
    32     private List<Movie> acts_in;
     65    public String getType() {
     66        return type;
     67    }
     68
     69    public void setType(String type) {
     70        this.type = type;
     71    }
     72
     73    public Date getDateOfBirth() {
     74        return dateOfBirth;
     75    }
     76
     77    public void setDateOfBirth(Date dateOfBirth) {
     78        this.dateOfBirth = dateOfBirth;
     79    }
     80
     81    public String getImageUrl() {
     82        return imageUrl;
     83    }
     84
     85    public void setImageUrl(String imageUrl) {
     86        this.imageUrl = imageUrl;
     87    }
     88
     89    public String getDescription() {
     90        return description;
     91    }
     92
     93    public void setDescription(String description) {
     94        this.description = description;
     95    }
     96
     97    @Override
     98    public boolean equals(Object o) {
     99        if (this == o) return true;
     100        if (o == null || getClass() != o.getClass()) return false;
     101
     102        Person that = (Person) o;
     103
     104        if (personId != that.personId) return false;
     105        if (name != null ? !name.equals(that.name) : that.name != null) return false;
     106        if (surname != null ? !surname.equals(that.surname) : that.surname != null) return false;
     107        if (type != null ? !type.equals(that.type) : that.type != null) return false;
     108        if (dateOfBirth != null ? !dateOfBirth.equals(that.dateOfBirth) : that.dateOfBirth != null) return false;
     109        if (imageUrl != null ? !imageUrl.equals(that.imageUrl) : that.imageUrl != null) return false;
     110        if (description != null ? !description.equals(that.description) : that.description != null) return false;
     111
     112        return true;
     113    }
     114
     115    @Override
     116    public int hashCode() {
     117        int result = personId;
     118        result = 31 * result + (name != null ? name.hashCode() : 0);
     119        result = 31 * result + (surname != null ? surname.hashCode() : 0);
     120        result = 31 * result + (type != null ? type.hashCode() : 0);
     121        result = 31 * result + (dateOfBirth != null ? dateOfBirth.hashCode() : 0);
     122        result = 31 * result + (imageUrl != null ? imageUrl.hashCode() : 0);
     123        result = 31 * result + (description != null ? description.hashCode() : 0);
     124        return result;
     125    }
     126
     127    public Collection<Discussion> getDiscussionsByPersonId() {
     128        return discussionsByPersonId;
     129    }
     130
     131    public void setDiscussionsByPersonId(Collection<Discussion> discussionsByPersonId) {
     132        this.discussionsByPersonId = discussionsByPersonId;
     133    }
     134
     135    public Collection<MovieActorsEntity> getMovieActorsByPersonId() {
     136        return movieActorsByPersonId;
     137    }
     138
     139    public void setMovieActorsByPersonId(Collection<MovieActorsEntity> movieActorsByPersonId) {
     140        this.movieActorsByPersonId = movieActorsByPersonId;
     141    }
     142
     143    public Collection<Movie> getMoviesByPersonId() {
     144        return moviesByPersonId;
     145    }
     146
     147    public void setMoviesByPersonId(Collection<Movie> moviesByPersonId) {
     148        this.moviesByPersonId = moviesByPersonId;
     149    }
     150
     151    public Collection<PersonRatesEntity> getPersonRatesByPersonId() {
     152        return personRatesByPersonId;
     153    }
     154
     155    public void setPersonRatesByPersonId(Collection<PersonRatesEntity> personRatesByPersonId) {
     156        this.personRatesByPersonId = personRatesByPersonId;
     157    }
    33158}
    34 
    35 
    36 /*
    37         create table persons(
    38         person_id serial primary key,
    39         name varchar(100) not null,
    40         surname varchar(100) not null,
    41         type char(1) not null,
    42         date_of_birth date not null,
    43         image_url varchar(300) not null,
    44         description varchar(300) not null,
    45         constraint ck_type check (type ='A' or type='D')
    46     );
    47  */
  • 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  */
  • src/main/java/com/wediscussmovies/project/model/User.java

    r839f96a r2d57cad  
    22
    33import javax.persistence.*;
    4 import java.util.List;
     4import java.util.Collection;
    55
    6 @Entity(name="users")
     6@Entity
     7@Table(name = "users", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies")
    78public class User {
     9    @GeneratedValue(strategy = GenerationType.IDENTITY)
    810    @Id
    9     @GeneratedValue
    10     @Column(name="user_id", nullable = false)
    11     private int user_id;
     11    @Column(name = "user_id")
     12    private int userId;
     13    @Basic
     14    @Column(name = "username")
     15    private String username;
     16    @Basic
     17    @Column(name = "name")
     18    private String name;
     19    @Basic
     20    @Column(name = "surname")
     21    private String surname;
     22    @Basic
     23    @Column(name = "email")
     24    private String email;
     25    @Basic
     26    @Column(name = "password")
     27    private String password;
     28    @OneToMany(mappedBy = "usersByUserId")
     29    private Collection<Discussion> discussionsByUserId;
     30    @OneToMany(mappedBy = "usersByUserId")
     31    private Collection<MovieLikesEntity> movieLikesByUserId;
     32    @OneToMany(mappedBy = "usersByUserId")
     33    private Collection<MovieRatesEntity> movieRatesByUserId;
     34    @OneToMany(mappedBy = "usersByUserId")
     35    private Collection<PersonRatesEntity> personRatesByUserId;
     36    @OneToMany(mappedBy = "usersByUserId")
     37    private Collection<Reply> repliesByUserId;
     38    @OneToMany(mappedBy = "usersByUserId")
     39    private Collection<UserGenresEntity> userGenresByUserId;
    1240
    13     @Column(name="username", length=50, nullable=false, unique=false)
    14     private String username;
     41    public int getUserId() {
     42        return userId;
     43    }
    1544
    16     @Column(name="name", length=50, nullable=false, unique=false)
    17     private String name;
     45    public void setUserId(int userId) {
     46        this.userId = userId;
     47    }
    1848
    19     @Column(name="surname", length=50, nullable=false, unique=false)
    20     private String surname;
     49    public String getUsername() {
     50        return username;
     51    }
    2152
    22     @Column(name="email", length=50, nullable=false, unique=false)
    23     private String email;
     53    public void setUsername(String username) {
     54        this.username = username;
     55    }
    2456
    25     @Column(name="password", length=100, nullable=false, unique=true)
    26     private String password;
     57    public String getName() {
     58        return name;
     59    }
    2760
    28     //TODO("RATES_MOVIE")
    29     @ManyToMany(mappedBy = "movie_likes")
    30     private List<Movie> likes_movie;
     61    public void setName(String name) {
     62        this.name = name;
     63    }
    3164
    32     @ManyToMany(mappedBy = "user_genres")
    33     private List<Genre> likes_genres;
     65    public String getSurname() {
     66        return surname;
     67    }
    3468
     69    public void setSurname(String surname) {
     70        this.surname = surname;
     71    }
     72
     73    public String getEmail() {
     74        return email;
     75    }
     76
     77    public void setEmail(String email) {
     78        this.email = email;
     79    }
     80
     81    public String getPassword() {
     82        return password;
     83    }
     84
     85    public void setPassword(String password) {
     86        this.password = password;
     87    }
     88
     89    @Override
     90    public boolean equals(Object o) {
     91        if (this == o) return true;
     92        if (o == null || getClass() != o.getClass()) return false;
     93
     94        User that = (User) o;
     95
     96        if (userId != that.userId) return false;
     97        if (username != null ? !username.equals(that.username) : that.username != null) return false;
     98        if (name != null ? !name.equals(that.name) : that.name != null) return false;
     99        if (surname != null ? !surname.equals(that.surname) : that.surname != null) return false;
     100        if (email != null ? !email.equals(that.email) : that.email != null) return false;
     101        if (password != null ? !password.equals(that.password) : that.password != null) return false;
     102
     103        return true;
     104    }
     105
     106    @Override
     107    public int hashCode() {
     108        int result = userId;
     109        result = 31 * result + (username != null ? username.hashCode() : 0);
     110        result = 31 * result + (name != null ? name.hashCode() : 0);
     111        result = 31 * result + (surname != null ? surname.hashCode() : 0);
     112        result = 31 * result + (email != null ? email.hashCode() : 0);
     113        result = 31 * result + (password != null ? password.hashCode() : 0);
     114        return result;
     115    }
     116
     117    public Collection<Discussion> getDiscussionsByUserId() {
     118        return discussionsByUserId;
     119    }
     120
     121    public void setDiscussionsByUserId(Collection<Discussion> discussionsByUserId) {
     122        this.discussionsByUserId = discussionsByUserId;
     123    }
     124
     125    public Collection<MovieLikesEntity> getMovieLikesByUserId() {
     126        return movieLikesByUserId;
     127    }
     128
     129    public void setMovieLikesByUserId(Collection<MovieLikesEntity> movieLikesByUserId) {
     130        this.movieLikesByUserId = movieLikesByUserId;
     131    }
     132
     133    public Collection<MovieRatesEntity> getMovieRatesByUserId() {
     134        return movieRatesByUserId;
     135    }
     136
     137    public void setMovieRatesByUserId(Collection<MovieRatesEntity> movieRatesByUserId) {
     138        this.movieRatesByUserId = movieRatesByUserId;
     139    }
     140
     141    public Collection<PersonRatesEntity> getPersonRatesByUserId() {
     142        return personRatesByUserId;
     143    }
     144
     145    public void setPersonRatesByUserId(Collection<PersonRatesEntity> personRatesByUserId) {
     146        this.personRatesByUserId = personRatesByUserId;
     147    }
     148
     149    public Collection<Reply> getRepliesByUserId() {
     150        return repliesByUserId;
     151    }
     152
     153    public void setRepliesByUserId(Collection<Reply> repliesByUserId) {
     154        this.repliesByUserId = repliesByUserId;
     155    }
     156
     157    public Collection<UserGenresEntity> getUserGenresByUserId() {
     158        return userGenresByUserId;
     159    }
     160
     161    public void setUserGenresByUserId(Collection<UserGenresEntity> userGenresByUserId) {
     162        this.userGenresByUserId = userGenresByUserId;
     163    }
    35164}
    36 
    37 
    38 /*
    39     create table users(
    40       user_id serial primary key,
    41       username varchar(50) not null unique,
    42       name varchar(50) not null,
    43       surname varchar(50) not null,
    44       email varchar(100) not null unique,
    45       password varchar(30) not null,
    46       constraint ck_password check(length(password) >= 9)
    47     );
    48  */
Note: See TracChangeset for help on using the changeset viewer.