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 | |
---|
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 | @Entity
|
---|
13 | @Getter
|
---|
14 | @Setter
|
---|
15 | @ToString
|
---|
16 | @RequiredArgsConstructor
|
---|
17 | public 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.