Auditable.java

  1. package no.nav.data.common.auditing.domain;

  2. import com.fasterxml.jackson.annotation.JsonFilter;
  3. import jakarta.persistence.Column;
  4. import jakarta.persistence.EntityListeners;
  5. import jakarta.persistence.MappedSuperclass;
  6. import lombok.Getter;
  7. import lombok.Setter;
  8. import lombok.experimental.FieldNameConstants;
  9. import no.nav.data.common.auditing.AuditVersionListener;
  10. import org.springframework.data.annotation.CreatedBy;
  11. import org.springframework.data.annotation.CreatedDate;
  12. import org.springframework.data.annotation.LastModifiedBy;
  13. import org.springframework.data.annotation.LastModifiedDate;
  14. import org.springframework.data.annotation.Version;
  15. import org.springframework.data.jpa.domain.support.AuditingEntityListener;

  16. import java.time.LocalDateTime;

  17. @Getter
  18. @Setter
  19. @FieldNameConstants
  20. @MappedSuperclass
  21. @JsonFilter("relationFilter")
  22. @EntityListeners({AuditingEntityListener.class, AuditVersionListener.class})
  23. public abstract class Auditable {

  24.     @CreatedBy
  25.     @Column(name = "CREATED_BY")
  26.     protected String createdBy;

  27.     @CreatedDate
  28.     @Column(name = "CREATED_DATE")
  29.     protected LocalDateTime createdDate;

  30.     @LastModifiedBy
  31.     @Column(name = "LAST_MODIFIED_BY")
  32.     protected String lastModifiedBy;

  33.     @Version
  34.     @LastModifiedDate
  35.     @Column(name = "LAST_MODIFIED_DATE")
  36.     protected LocalDateTime lastModifiedDate;
  37. }