source: src/main/java/com/example/autopartz/model/Delivery.java

main
Last change on this file was f484b14, checked in by andrejtodorovski <82031894+andrejtodorovski@…>, 23 months ago

Added full functionality for creating order

  • 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@Entity
13@Getter
14@Setter
15@ToString
16@RequiredArgsConstructor
17public class Delivery {
18 @Id
19 @GeneratedValue(strategy = GenerationType.IDENTITY)
20 Integer ID_delivery;
21 @Column(name = "delivery_status")
22 String status;
23 @Column(name = "delivery_address")
24 String address;
25 @ManyToOne
26 @JoinColumn(name = "id_user")
27 Deliveryman deliveryman;
28 @JoinColumn(name = "id_order")
29 @OneToOne
30 Order order;
31
32 public Delivery(String status, String address, Deliveryman deliveryman, Order order) {
33 this.status = status;
34 this.address = address;
35 this.deliveryman = deliveryman;
36 this.order = order;
37 }
38
39 @Override
40 public boolean equals(Object o) {
41 if (this == o) return true;
42 if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
43 Delivery delivery = (Delivery) o;
44 return ID_delivery != null && Objects.equals(ID_delivery, delivery.ID_delivery);
45 }
46
47 @Override
48 public int hashCode() {
49 return getClass().hashCode();
50 }
51}
Note: See TracBrowser for help on using the repository browser.