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
RevLine 
[2e46f06]1package com.example.autopartz.model;
2
[ae042f4]3import lombok.Getter;
4import lombok.RequiredArgsConstructor;
5import lombok.Setter;
6import lombok.ToString;
[2e46f06]7import org.hibernate.Hibernate;
8
[ae042f4]9import javax.persistence.*;
[2e46f06]10import java.util.Objects;
11
12@Getter
13@Setter
14@ToString
15@RequiredArgsConstructor
16@Entity
17@Table(name = "car")
18public class Car {
19 @Id
[84652fb]20 @GeneratedValue(strategy = GenerationType.IDENTITY)
[f484b14]21 @Column(name = "ID_car")
22 Integer id;
[2e46f06]23 Integer in_production_since;
24 Integer in_production_till;
[60de3eb]25 @Column(name = "car_type")
26 String cartype;
[2e46f06]27 @ManyToOne
28 @JoinColumn(name = "id_car_manufacturer")
29 CarManufacturer car_manufacturer;
30
[84652fb]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
[2e46f06]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;
[f484b14]43 return id != null && Objects.equals(id, car.id);
[2e46f06]44 }
45
46 @Override
47 public int hashCode() {
48 return getClass().hashCode();
49 }
50}
Note: See TracBrowser for help on using the repository browser.