source: src/main/java/com/example/autopartz/model/Price.java

main
Last change on this file was 4d67d70, checked in by andrejtodorovski <82031894+andrejtodorovski@…>, 23 months ago

Final touches

  • Property mode set to 100644
File size: 1.1 KB
Line 
1package com.example.autopartz.model;
2
3import lombok.Getter;
4import lombok.RequiredArgsConstructor;
5import lombok.Setter;
6import lombok.ToString;
7import org.hibernate.Hibernate;
8
9import javax.persistence.*;
10import java.time.LocalDate;
11import java.util.Objects;
12
13@Entity
14@Getter
15@Setter
16@ToString
17@RequiredArgsConstructor
18public class Price {
19 @Id
20 @GeneratedValue(strategy = GenerationType.IDENTITY)
21 Integer ID_price;
22 Integer amount;
23 LocalDate price_from;
24 LocalDate price_till;
25 @ManyToOne
26 @JoinColumn(name = "id_part")
27 Part part;
28
29 public Price(Integer amount, LocalDate price_from, Part part) {
30 this.amount = amount;
31 this.price_from = price_from;
32 this.part = part;
33 }
34
35 @Override
36 public boolean equals(Object o) {
37 if (this == o) return true;
38 if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
39 Price price = (Price) o;
40 return ID_price != null && Objects.equals(ID_price, price.ID_price);
41 }
42
43 @Override
44 public int hashCode() {
45 return getClass().hashCode();
46 }
47}
Note: See TracBrowser for help on using the repository browser.