1 | package com.example.autopartz.model;
|
---|
2 |
|
---|
3 | import lombok.Getter;
|
---|
4 | import lombok.RequiredArgsConstructor;
|
---|
5 | import lombok.Setter;
|
---|
6 | import lombok.ToString;
|
---|
7 | import org.hibernate.Hibernate;
|
---|
8 |
|
---|
9 | import javax.persistence.*;
|
---|
10 | import java.util.List;
|
---|
11 | import java.util.Objects;
|
---|
12 |
|
---|
13 | @Getter
|
---|
14 | @Setter
|
---|
15 | @ToString
|
---|
16 | @RequiredArgsConstructor
|
---|
17 | @Entity
|
---|
18 | @Table(name = "repair_shop")
|
---|
19 | public class RepairShop {
|
---|
20 | @Id
|
---|
21 | @Column(name = "ID_repair_shop")
|
---|
22 | @GeneratedValue(strategy = GenerationType.IDENTITY)
|
---|
23 | Integer id;
|
---|
24 | @Column(name = "rs_name")
|
---|
25 | String name;
|
---|
26 | @Column(name = "rs_location")
|
---|
27 | String location;
|
---|
28 | @Column(name = "rs_phone_number")
|
---|
29 | String number;
|
---|
30 | @ManyToMany
|
---|
31 | @JoinTable(name = "repair_shop_is_authorized_for_car_make", joinColumns =
|
---|
32 | @JoinColumn(name = "id_repair_shop"),
|
---|
33 | inverseJoinColumns = @JoinColumn(name = "id_car_manufacturer"))
|
---|
34 | @ToString.Exclude
|
---|
35 | List<CarManufacturer> carManufacturerList;
|
---|
36 |
|
---|
37 | public RepairShop(String name, String location, String number, List<CarManufacturer> carManufacturerList) {
|
---|
38 | this.name = name;
|
---|
39 | this.location = location;
|
---|
40 | this.number = number;
|
---|
41 | this.carManufacturerList = carManufacturerList;
|
---|
42 | }
|
---|
43 |
|
---|
44 | @Override
|
---|
45 | public boolean equals(Object o) {
|
---|
46 | if (this == o) return true;
|
---|
47 | if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
---|
48 | RepairShop that = (RepairShop) o;
|
---|
49 | return id != null && Objects.equals(id, that.id);
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Override
|
---|
53 | public int hashCode() {
|
---|
54 | return getClass().hashCode();
|
---|
55 | }
|
---|
56 | }
|
---|