Skip to content

Commit 862f9f7

Browse files
Rajeev Kumar Singhcallicoder
Rajeev Kumar Singh
authored andcommitted
updatable=false in createdAt and createdBy
1 parent 50da247 commit 862f9f7

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

polling-app-server/src/main/java/com/example/polls/model/audit/DateAudit.java

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.springframework.data.annotation.LastModifiedDate;
66
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
77

8+
import javax.persistence.Column;
89
import javax.persistence.EntityListeners;
910
import javax.persistence.MappedSuperclass;
1011
import java.io.Serializable;
@@ -19,9 +20,11 @@
1920
public abstract class DateAudit implements Serializable {
2021

2122
@CreatedDate
23+
@Column(nullable = false, updatable = false)
2224
private Instant createdAt;
2325

2426
@LastModifiedDate
27+
@Column(nullable = false)
2528
private Instant updatedAt;
2629

2730
public Instant getCreatedAt() {

polling-app-server/src/main/java/com/example/polls/model/audit/UserDateAudit.java

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.data.annotation.CreatedBy;
55
import org.springframework.data.annotation.LastModifiedBy;
66

7+
import javax.persistence.Column;
78
import javax.persistence.MappedSuperclass;
89

910
/**
@@ -18,6 +19,7 @@
1819
public abstract class UserDateAudit extends DateAudit {
1920

2021
@CreatedBy
22+
@Column(updatable = false)
2123
private Long createdBy;
2224

2325
@LastModifiedBy

0 commit comments

Comments
 (0)