main
Last change
on this file was 84652fb, checked in by andrejtodorovski <82031894+andrejtodorovski@…>, 23 months ago |
Admin views for adding things to the database
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
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.Objects;
|
---|
11 |
|
---|
12 | @Getter
|
---|
13 | @Setter
|
---|
14 | @ToString
|
---|
15 | @RequiredArgsConstructor
|
---|
16 | @Entity
|
---|
17 | @Table(name = "car")
|
---|
18 | public class Car {
|
---|
19 | @Id
|
---|
20 | @GeneratedValue(strategy = GenerationType.IDENTITY)
|
---|
21 | @Column(name = "ID_car")
|
---|
22 | Integer id;
|
---|
23 | Integer in_production_since;
|
---|
24 | Integer in_production_till;
|
---|
25 | @Column(name = "car_type")
|
---|
26 | String cartype;
|
---|
27 | @ManyToOne
|
---|
28 | @JoinColumn(name = "id_car_manufacturer")
|
---|
29 | CarManufacturer car_manufacturer;
|
---|
30 |
|
---|
31 | public Car(Integer in_production_since, Integer in_production_till, String cartype, CarManufacturer car_manufacturer) {
|
---|
32 | this.in_production_since = in_production_since;
|
---|
33 | this.in_production_till = in_production_till;
|
---|
34 | this.cartype = cartype;
|
---|
35 | this.car_manufacturer = car_manufacturer;
|
---|
36 | }
|
---|
37 |
|
---|
38 | @Override
|
---|
39 | public boolean equals(Object o) {
|
---|
40 | if (this == o) return true;
|
---|
41 | if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
|
---|
42 | Car car = (Car) o;
|
---|
43 | return id != null && Objects.equals(id, car.id);
|
---|
44 | }
|
---|
45 |
|
---|
46 | @Override
|
---|
47 | public int hashCode() {
|
---|
48 | return getClass().hashCode();
|
---|
49 | }
|
---|
50 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.