[2e46f06] | 1 | package com.example.autopartz.model;
|
---|
| 2 |
|
---|
[23a2bc5] | 3 | import jakarta.persistence.*;
|
---|
[eaf0f1b] | 4 | import lombok.Getter;
|
---|
| 5 | import lombok.RequiredArgsConstructor;
|
---|
| 6 | import lombok.Setter;
|
---|
| 7 | import lombok.ToString;
|
---|
[2e46f06] | 8 | import org.hibernate.Hibernate;
|
---|
| 9 |
|
---|
[23a2bc5] | 10 | import java.util.List;
|
---|
[2e46f06] | 11 | import java.util.Objects;
|
---|
| 12 |
|
---|
| 13 | @Getter
|
---|
| 14 | @Setter
|
---|
| 15 | @ToString
|
---|
| 16 | @RequiredArgsConstructor
|
---|
| 17 | @Entity
|
---|
| 18 | public class Part {
|
---|
| 19 | @Id
|
---|
[feffc2f] | 20 | @Column(name = "ID_part")
|
---|
| 21 | Long id;
|
---|
| 22 | @Column(name = "part_name")
|
---|
| 23 | String name;
|
---|
| 24 | @Column(name = "part_description")
|
---|
| 25 | String description;
|
---|
[2e46f06] | 26 | @ManyToOne
|
---|
| 27 | @JoinColumn(name = "id_part_manufacturer")
|
---|
[feffc2f] | 28 | PartManufacturer manufacturer;
|
---|
[23a2bc5] | 29 | @ManyToMany
|
---|
| 30 | @JoinTable(name = "part_is_from_category", joinColumns =
|
---|
| 31 | @JoinColumn(name = "id_part"),
|
---|
| 32 | inverseJoinColumns = @JoinColumn(name = "id_category"))
|
---|
| 33 | @ToString.Exclude
|
---|
| 34 | List<Category> categoryList;
|
---|
[eaf0f1b] | 35 | @ManyToMany
|
---|
| 36 | @JoinTable(name = "part_is_in_stock_in_warehouse", joinColumns =
|
---|
| 37 | @JoinColumn(name = "id_part"),
|
---|
| 38 | inverseJoinColumns = @JoinColumn(name = "id_warehouse"))
|
---|
| 39 | @ToString.Exclude
|
---|
| 40 | List<Warehouse> warehouseList;
|
---|
| 41 | @ManyToMany
|
---|
| 42 | @JoinTable(name = "part_is_appropriate_for_car", joinColumns =
|
---|
| 43 | @JoinColumn(name = "id_part"),
|
---|
| 44 | inverseJoinColumns = @JoinColumn(name = "id_car"))
|
---|
| 45 | @ToString.Exclude
|
---|
| 46 | List<Car> carList;
|
---|
[2e46f06] | 47 |
|
---|
| 48 | @Override
|
---|
| 49 | public boolean equals(Object o) {
|
---|
| 50 | if (this == o) return true;
|
---|
| 51 | if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
---|
| 52 | Part part = (Part) o;
|
---|
[feffc2f] | 53 | return id != null && Objects.equals(id, part.id);
|
---|
[2e46f06] | 54 | }
|
---|
| 55 |
|
---|
| 56 | @Override
|
---|
| 57 | public int hashCode() {
|
---|
| 58 | return getClass().hashCode();
|
---|
| 59 | }
|
---|
| 60 | }
|
---|