source: Git/src/main/java/com/wediscussmovies/project/model/Person.java@ 2a5d6a3

main
Last change on this file since 2a5d6a3 was 2a5d6a3, checked in by Petar Partaloski <ppartaloski@…>, 2 years ago

Controller, Repository and Service layer improvements, Entity updating

  • Property mode set to 100644
File size: 1.7 KB
Line 
1package com.wediscussmovies.project.model;
2
3import lombok.Data;
4
5import javax.persistence.*;
6import java.sql.Date;
7import java.util.Comparator;
8import java.util.List;
9
10@Data
11@Entity
12@Table(name="persons")
13public class Person {
14 @Id
15 @GeneratedValue
16 private int person_id;
17
18 @Column(name="name", length=100, nullable=false, unique=false)
19 private String name;
20
21 @Column(name="surname", length=100, nullable=false, unique=false)
22 private String surname;
23
24 @Column(name="type", nullable = false)
25 private PersonType personType;
26
27 @Column(name="date_of_birth", nullable=false)
28 private Date date_of_birth;
29
30 @Column(name="image_url", length=300, nullable=false, unique=false)
31 private String image_url;
32
33 @Column(name="description", length=300, nullable=false, unique=false)
34 private String description;
35
36 @ManyToMany
37 private List<Movie> acts_in;
38
39 public Person(String name, String surname, PersonType personType, Date date_of_birth, String image_url, String description) {
40 this.name = name;
41 this.surname = surname;
42 this.personType = personType;
43 this.date_of_birth = date_of_birth;
44 this.image_url = image_url;
45 this.description = description;
46 }
47
48 public Person() {
49 }
50
51 public static Comparator<Person> personComparatorByNameSurname = Comparator.comparing(Person::getName).thenComparing(Person::getSurname);
52}
53
54
55/*
56 create table persons(
57 person_id serial primary key,
58 name varchar(100) not null,
59 surname varchar(100) not null,
60 type char(1) not null,
61 date_of_birth date not null,
62 image_url varchar(300) not null,
63 description varchar(300) not null,
64 constraint ck_type check (type ='A' or type='D')
65 );
66 */
Note: See TracBrowser for help on using the repository browser.