package dev.nincodedo.ninbot.common.persistence;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import java.time.LocalDateTime;

@Data
@MappedSuperclass
@AllArgsConstructor
@NoArgsConstructor
public class BaseEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(nullable = false)
    @EqualsAndHashCode.Exclude
    private Long id;
    @Embedded
    private AuditMetadata audit = new AuditMetadata();

    @PrePersist
    private void prePersist() {
        audit.setCreatedDateTime(LocalDateTime.now());
    }

    @PreUpdate
    private void preUpdate() {
        audit.setModifiedDateTime(LocalDateTime.now());
    }
}


@@ -386,16 +386,51 @@
 rclass;%0A
+import javax.persistence.PostLoad;%0A
 import j
@@ -832,16 +832,147 @@
 ata();%0A%0A
+    @PostLoad%0A    private void postLoad() %7B%0A        if (audit == null) %7B%0A            audit = new AuditMetadata();%0A        %7D%0A    %7D%0A%0A
     @Pre

Fix more audit issues