source: src/main/java/com/example/autopartz/model/Car.java@ 84652fb

main
Last change on this file since 84652fb was 84652fb, checked in by andrejtodorovski <82031894+andrejtodorovski@…>, 18 months ago

Admin views for adding things to the database

  • Property mode set to 100644
File size: 1.3 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.util.Objects;
11
12@Getter
13@Setter
14@ToString
15@RequiredArgsConstructor
16@Entity
17@Table(name = "car")
18public 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.