/** * @author Oliver Gierke */ @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class AbstractEntity { @Id @GeneratedValue Long id; @CreatedDate LocalDateTime createdDate; @LastModifiedDate LocalDateTime modifiedDate; }
/** * User domain class that uses auditing functionality of Spring Data that can either be aquired implementing * {@link Auditable} or extend {@link AbstractAuditable}. * * @author Oliver Gierke * @author Thomas Darimont */ @Data @Entity @EntityListeners(AuditingEntityListener.class) public class AuditableUser { private @Id @GeneratedValue Long id; private String username; private @CreatedDate LocalDateTime createdDate; private @LastModifiedDate LocalDateTime lastModifiedDate; private @ManyToOne @CreatedBy AuditableUser createdBy; private @ManyToOne @LastModifiedBy AuditableUser lastModifiedBy; }
@CreatedDate private Date createdAt;
@CreatedDate private Date createdAt;
public class BaseEntity { @CreatedDate private Long createdAt;
public class BaseEntity { @CreatedDate private Long createdAt;
public class BaseEntity { @CreatedDate private Long createdAt;
private String createBy; @CreatedDate @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@CreatedDate private Date createdDateTime;
@CreatedDate @Temporal(TemporalType.TIMESTAMP) @Column(name = "CREATED", nullable = true) public Date getCreated() { return created; }
@Data @ToString @Builder @NoArgsConstructor @AllArgsConstructor class Post { @Id private String id; private String title; private String content; @CreatedDate private LocalDateTime createdDate; }
@CreatedDate public void setCreatedAt(final long createdAt) { this.createdAt = createdAt; // In general modification audit entry is not changed by the controller. // However, we want to stay consistent with // EnableJpaAuditing#modifyOnCreate=true. if (isController()) { this.lastModifiedAt = createdAt; } }
@CreatedDate public void setCreatedAt(final long createdAt) { this.createdAt = createdAt; // In general modification audit entry is not changed by the controller. // However, we want to stay consistent with // EnableJpaAuditing#modifyOnCreate=true. if (isController()) { this.lastModifiedAt = createdAt; } }
@Embeddable @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) public class DateTime { @CreatedDate @Column(name = "created_at", updatable = false) private LocalDateTime createdAt; @LastModifiedDate @Column(name = "update_at") private LocalDateTime updatedAt; }
@Document @Data @ToString @Builder @NoArgsConstructor @AllArgsConstructor class Post { @Id private String id; private String title; private String content; @CreatedDate private LocalDateTime createdDate; }
@Document @Data @ToString @Builder @NoArgsConstructor @AllArgsConstructor class Post { @Id private String id; private String title; private String content; @CreatedDate private LocalDateTime createdDate; }
@Document @Data @ToString @Builder @NoArgsConstructor @AllArgsConstructor class Post { @Id private String id; private String title; private String content; @CreatedDate private LocalDateTime createdDate; }
@Document @Data @ToString @Builder @NoArgsConstructor @AllArgsConstructor class Post { @Id private String id; private String title; private String content; @CreatedDate private LocalDateTime createdDate; }
@Document @Data @ToString @Builder @NoArgsConstructor @AllArgsConstructor class Post { @Id private String id; private String title; private String content; @CreatedDate private LocalDateTime createdDate; }
@Document @Data @ToString @Builder @NoArgsConstructor @AllArgsConstructor class Post { @Id private String id; private String title; private String content; @CreatedDate private LocalDateTime createdDate; }