-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathBook.java
More file actions
62 lines (51 loc) · 1.49 KB
/
Book.java
File metadata and controls
62 lines (51 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package io.bcn.springConference.model;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;
import java.util.Objects;
import java.util.UUID;
@Entity
@Table(name = "books")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Book {
@Id
@GeneratedValue(generator = "UUID")
@GenericGenerator(name = "UUID",
strategy = "org.hibernate.id.UUIDGenerator")
@Column(name = "id", updatable = false,
nullable = false)
private UUID id;
@Column(nullable = false)
private String title;
@Column(nullable = false)
private String author;
@Column(nullable = false, unique = true)
private String ISBN;
/* @OneToMany(mappedBy = "book")
private List<Conference> conferences;*/
// https://stackoverflow.com/questions/17298314/java-vaadin-nativeselect-setvalue-not-working/17299605#17299605
@Override
public boolean equals(Object obj) {
if(this == obj) {
return true;
}
if(!(obj instanceof Book)){
return false;
}
Book that = (Book) obj;
return this.id.equals(that.id) &&
this.author.equals(that.author) &&
this.title.equals(that.title) &&
this.ISBN.equals(that.ISBN);
}
@Override
public int hashCode() {
return Objects.hash(id, title, author, ISBN);
}
}