-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseJobEntity.java
116 lines (97 loc) · 2.99 KB
/
BaseJobEntity.java
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.payoneer.JobManagement.domain.entities;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.InstantSerializer;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import javax.persistence.*;
import java.time.Instant;
import java.util.UUID;
/**
* Core WareHouse, POJO Entity class. superclass for all other classes that intend to use the API,
* it contains the general shape of any table contains the id and dates objects.
*
* @author Feras E Alawadi
* @version 1.0.101
* @since 1.0.101
*/
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class BaseJobEntity {
/**
* to used RDMS System Please UnComment the lines and comment the active ones.
* H2 Database need a different type support fo UUIDs.
*/
@Id
// uncomment to use RDMS like MYSQL
//@Type(type = "org.hibernate.type.UUIDCharType")
// uncomment to use RDMS like MYSQL
// @Column(name = "id", columnDefinition = "BINARY(36)", updatable = false, nullable = false)
// comment to use RDMS like MYSQL
@Column(name = "id")
// comment to use RDMS like MYSQL
@GenericGenerator(name = "uuid", strategy = "uuid4")
protected UUID id;
/**
* resource create Date
*/
@CreatedDate
@Column(nullable = false, updatable = false)
@JsonDeserialize(using = InstantDeserializer.class)
@JsonSerialize(using = InstantSerializer.class)
private Instant created;
/**
* resource modification Date
*/
@LastModifiedDate
@JsonDeserialize(using = InstantDeserializer.class)
@JsonSerialize(using = InstantSerializer.class)
private Instant modified;
/**
* our API Version
*/
@Version
protected int version = 1;
public BaseJobEntity(UUID id, Instant created) {
this.id = id;
this.created = created;
}
public BaseJobEntity() {
}
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public Instant getCreated() {
return created;
}
public void setCreated(Instant created) {
this.created = created;
}
public Instant getModified() {
return modified;
}
public void setModified(Instant modified) {
this.modified = modified;
}
public int getVersion() {
return version;
}
public void setVersion(int version) {
this.version = version;
}
@Override
public String toString() {
return "BaseJobEntity{" +
"id=" + id +
", created=" + created +
", modified=" + modified +
", version='" + version + '\'' +
'}';
}
}