1 | package com.example.baza.model;
|
---|
2 |
|
---|
3 | import lombok.NoArgsConstructor;
|
---|
4 |
|
---|
5 | import javax.persistence.*;
|
---|
6 | import java.time.LocalDate;
|
---|
7 | import java.util.LinkedHashSet;
|
---|
8 | import java.util.Set;
|
---|
9 |
|
---|
10 | @Entity
|
---|
11 | @Table(name = "pozajmica", schema = "project")
|
---|
12 | @NoArgsConstructor
|
---|
13 | public class Pozajmica {
|
---|
14 | @Id
|
---|
15 | @GeneratedValue(strategy = GenerationType.IDENTITY)
|
---|
16 | @Column(name = "id_na_pozajmica", nullable = false)
|
---|
17 | private Integer id;
|
---|
18 |
|
---|
19 | @Column(name = "datum_na_zemanje", nullable = false)
|
---|
20 | private LocalDate datumNaZemanje;
|
---|
21 |
|
---|
22 | @Column(name = "datum_na_vrakjanje", nullable = false)
|
---|
23 | private LocalDate datumNaVrakjanje;
|
---|
24 |
|
---|
25 | @Column(name = "status", nullable = false)
|
---|
26 | private Boolean status = false;
|
---|
27 |
|
---|
28 | @ManyToOne(fetch = FetchType.LAZY, optional = false)
|
---|
29 | @JoinColumn(name = "id_chovek_odobruva", nullable = false)
|
---|
30 | private Bibliotekar2 bibliotekar;
|
---|
31 |
|
---|
32 | @ManyToOne(fetch = FetchType.LAZY, optional = false)
|
---|
33 | @JoinColumn(name = "id_chovek_prave", nullable = false)
|
---|
34 | private Chlen2 chlen;
|
---|
35 |
|
---|
36 | @ManyToOne(fetch = FetchType.LAZY, optional = false)
|
---|
37 | @JoinColumns({
|
---|
38 | @JoinColumn(name = "id_na_kniga", referencedColumnName = "id_na_kniga", nullable = false),
|
---|
39 | @JoinColumn(name = "unique_id", referencedColumnName = "unique_id", nullable = false)
|
---|
40 | })
|
---|
41 | private InstancaOdKniga instancaOdKniga;
|
---|
42 | @OneToMany(mappedBy = "pozajmica")
|
---|
43 | private Set<Kazna> kaznas = new LinkedHashSet<>();
|
---|
44 |
|
---|
45 | public Pozajmica(LocalDate datumNaZemanje, LocalDate datumNaVrakjanje, Boolean status, Bibliotekar2 bibliotekar, Chlen2 chlen, InstancaOdKniga instanca) {
|
---|
46 | }
|
---|
47 |
|
---|
48 | public Set<Kazna> getKaznas() {
|
---|
49 | return kaznas;
|
---|
50 | }
|
---|
51 |
|
---|
52 | public void setKaznas(Set<Kazna> kaznas) {
|
---|
53 | this.kaznas = kaznas;
|
---|
54 | }
|
---|
55 | public InstancaOdKniga getInstancaOdKniga() {
|
---|
56 | return instancaOdKniga;
|
---|
57 | }
|
---|
58 |
|
---|
59 | public void setInstancaOdKniga(InstancaOdKniga instancaOdKniga) {
|
---|
60 | this.instancaOdKniga = instancaOdKniga;
|
---|
61 | }
|
---|
62 |
|
---|
63 | public Chlen2 getChlen() {
|
---|
64 | return chlen;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public void setChlen(Chlen2 chlen) {
|
---|
68 | this.chlen = chlen;
|
---|
69 | }
|
---|
70 |
|
---|
71 | public Bibliotekar2 getBibliotekar() {
|
---|
72 | return bibliotekar;
|
---|
73 | }
|
---|
74 |
|
---|
75 | public void setBibliotekar(Bibliotekar2 bibliotekar) {
|
---|
76 | this.bibliotekar = bibliotekar;
|
---|
77 | }
|
---|
78 |
|
---|
79 | public Boolean getStatus() {
|
---|
80 | return status;
|
---|
81 | }
|
---|
82 |
|
---|
83 | public void setStatus(Boolean status) {
|
---|
84 | this.status = status;
|
---|
85 | }
|
---|
86 |
|
---|
87 | public LocalDate getDatumNaVrakjanje() {
|
---|
88 | return datumNaVrakjanje;
|
---|
89 | }
|
---|
90 |
|
---|
91 | public void setDatumNaVrakjanje(LocalDate datumNaVrakjanje) {
|
---|
92 | this.datumNaVrakjanje = datumNaVrakjanje;
|
---|
93 | }
|
---|
94 |
|
---|
95 | public LocalDate getDatumNaZemanje() {
|
---|
96 | return datumNaZemanje;
|
---|
97 | }
|
---|
98 |
|
---|
99 | public void setDatumNaZemanje(LocalDate datumNaZemanje) {
|
---|
100 | this.datumNaZemanje = datumNaZemanje;
|
---|
101 | }
|
---|
102 |
|
---|
103 | public Integer getId() {
|
---|
104 | return id;
|
---|
105 | }
|
---|
106 |
|
---|
107 | public void setId(Integer id) {
|
---|
108 | this.id = id;
|
---|
109 | }
|
---|
110 |
|
---|
111 | //TODO Reverse Engineering! Migrate other columns to the entity
|
---|
112 |
|
---|
113 | public Pozajmica(LocalDate datumNaZemanje, LocalDate datumNaVrakjanje, Boolean status, Bibliotekar2 bibliotekar, Chlen2 chlen, InstancaOdKniga instancaOdKniga, Set<Kazna> kaznas) {
|
---|
114 | this.datumNaZemanje = datumNaZemanje;
|
---|
115 | this.datumNaVrakjanje = datumNaVrakjanje;
|
---|
116 | this.status = status;
|
---|
117 | this.bibliotekar = bibliotekar;
|
---|
118 | this.chlen = chlen;
|
---|
119 | this.instancaOdKniga = instancaOdKniga;
|
---|
120 | this.kaznas = kaznas;
|
---|
121 | }
|
---|
122 |
|
---|
123 | public Pozajmica(Integer id, LocalDate datumNaZemanje, LocalDate datumNaVrakjanje, Boolean status, Bibliotekar2 bibliotekar, Chlen2 chlen, InstancaOdKniga instancaOdKniga, Set<Kazna> kaznas) {
|
---|
124 | this.id = id;
|
---|
125 | this.datumNaZemanje = datumNaZemanje;
|
---|
126 | this.datumNaVrakjanje = datumNaVrakjanje;
|
---|
127 | this.status = status;
|
---|
128 | this.bibliotekar = bibliotekar;
|
---|
129 | this.chlen = chlen;
|
---|
130 | this.instancaOdKniga = instancaOdKniga;
|
---|
131 | this.kaznas = kaznas;
|
---|
132 | }
|
---|
133 | } |
---|