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

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.0 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
17public class Category {
18 @Id
19 @Column(name = "id_category")
20 @GeneratedValue(strategy = GenerationType.IDENTITY)
21 Integer id;
22 @Column(name = "category_name")
23 String cname;
24 @ManyToOne
25 @JoinColumn(name = "id_parent_category")
26 Category ID_parent_category;
27
28 public Category(String category) {
29 this.cname = category;
30 }
31
32 @Override
33 public boolean equals(Object o) {
34 if (this == o) return true;
35 if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
36 Category category = (Category) o;
37 return id != null && Objects.equals(id, category.id);
38 }
39
40 @Override
41 public int hashCode() {
42 return getClass().hashCode();
43 }
44}
Note: See TracBrowser for help on using the repository browser.