Changeset 2d57cad in Git for src/main/java/com/wediscussmovies/project/model/User.java
- Timestamp:
- 01/16/22 17:12:01 (3 years ago)
- Branches:
- main
- Children:
- 7fafead
- Parents:
- 839f96a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/wediscussmovies/project/model/User.java
r839f96a r2d57cad 2 2 3 3 import javax.persistence.*; 4 import java.util. List;4 import java.util.Collection; 5 5 6 @Entity(name="users") 6 @Entity 7 @Table(name = "users", schema = "project", catalog = "db_202122z_va_prj_wediscussmovies") 7 8 public class User { 9 @GeneratedValue(strategy = GenerationType.IDENTITY) 8 10 @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; 12 40 13 @Column(name="username", length=50, nullable=false, unique=false) 14 private String username; 41 public int getUserId() { 42 return userId; 43 } 15 44 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 } 18 48 19 @Column(name="surname", length=50, nullable=false, unique=false) 20 private String surname; 49 public String getUsername() { 50 return username; 51 } 21 52 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 } 24 56 25 @Column(name="password", length=100, nullable=false, unique=true) 26 private String password; 57 public String getName() { 58 return name; 59 } 27 60 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 } 31 64 32 @ManyToMany(mappedBy = "user_genres") 33 private List<Genre> likes_genres; 65 public String getSurname() { 66 return surname; 67 } 34 68 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 } 35 164 } 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.