-
Notifications
You must be signed in to change notification settings - Fork 65
/
AuditedEntity.java
46 lines (37 loc) · 1.13 KB
/
AuditedEntity.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
package com.shardis.api.domain.base;
import com.shardis.api.domain.user.User;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.envers.Audited;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.EntityListeners;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import java.time.LocalDateTime;
/**
* Created by Tomasz Kucharzyk
*/
@Audited
@Data
@EqualsAndHashCode(callSuper = true)
@EntityListeners(AuditingEntityListener.class)
@MappedSuperclass
public class AuditedEntity extends BaseEntity {
@CreatedDate
protected LocalDateTime createdDate;
@CreatedBy
@ManyToOne
protected User createdBy;
@LastModifiedDate
protected LocalDateTime updatedDate;
@LastModifiedBy
@ManyToOne
protected User updatedBy;
@Version
protected Long version;
}