[6e7b472] | 1 | package com.wediscussmovies.project.model;
|
---|
| 2 |
|
---|
[7a0bf79] | 3 | import lombok.Data;
|
---|
| 4 |
|
---|
[6e7b472] | 5 | import javax.persistence.*;
|
---|
| 6 | import java.util.List;
|
---|
| 7 |
|
---|
[7a0bf79] | 8 | @Data
|
---|
[2a5d6a3] | 9 | @Entity
|
---|
| 10 | @Table(name="users")
|
---|
[6e7b472] | 11 | public class User {
|
---|
| 12 | @Id
|
---|
| 13 | @GeneratedValue
|
---|
| 14 | @Column(name="user_id", nullable = false)
|
---|
| 15 | private int user_id;
|
---|
| 16 |
|
---|
| 17 | @Column(name="username", length=50, nullable=false, unique=false)
|
---|
| 18 | private String username;
|
---|
| 19 |
|
---|
| 20 | @Column(name="name", length=50, nullable=false, unique=false)
|
---|
| 21 | private String name;
|
---|
| 22 |
|
---|
| 23 | @Column(name="surname", length=50, nullable=false, unique=false)
|
---|
| 24 | private String surname;
|
---|
| 25 |
|
---|
| 26 | @Column(name="email", length=50, nullable=false, unique=false)
|
---|
| 27 | private String email;
|
---|
| 28 |
|
---|
| 29 | @Column(name="password", length=100, nullable=false, unique=true)
|
---|
| 30 | private String password;
|
---|
| 31 |
|
---|
| 32 | //TODO("RATES_MOVIE")
|
---|
| 33 | @ManyToMany(mappedBy = "movie_likes")
|
---|
| 34 | private List<Movie> likes_movie;
|
---|
| 35 |
|
---|
| 36 | @ManyToMany(mappedBy = "user_genres")
|
---|
| 37 | private List<Genre> likes_genres;
|
---|
| 38 |
|
---|
[2a5d6a3] | 39 | public User(String username, String name, String surname, String email, String password) {
|
---|
| 40 | this.username = username;
|
---|
| 41 | this.name = name;
|
---|
| 42 | this.surname = surname;
|
---|
| 43 | this.email = email;
|
---|
| 44 | this.password = password;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | public User() {
|
---|
| 48 | }
|
---|
[6e7b472] | 49 | }
|
---|
| 50 |
|
---|
| 51 |
|
---|
| 52 | /*
|
---|
| 53 | create table users(
|
---|
| 54 | user_id serial primary key,
|
---|
| 55 | username varchar(50) not null unique,
|
---|
| 56 | name varchar(50) not null,
|
---|
| 57 | surname varchar(50) not null,
|
---|
| 58 | email varchar(100) not null unique,
|
---|
| 59 | password varchar(30) not null,
|
---|
| 60 | constraint ck_password check(length(password) >= 9)
|
---|
| 61 | );
|
---|
| 62 | */ |
---|