/** * 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; }
@CreatedBy @Column(name = "CREATED_BY", nullable = true) public String getCreatedBy() { return createdBy; }
@CreatedBy public void setCreatedBy(final String createdBy) { if (isController()) { this.createdBy = "CONTROLLER_PLUG_AND_PLAY"; // In general modification audit entry is not changed by the // controller. However, we want to stay consistent with // EnableJpaAuditing#modifyOnCreate=true. this.lastModifiedBy = this.createdBy; return; } this.createdBy = createdBy; }
@CreatedBy public void setCreatedBy(final String createdBy) { if (isController()) { this.createdBy = "CONTROLLER_PLUG_AND_PLAY"; // In general modification audit entry is not changed by the // controller. However, we want to stay consistent with // EnableJpaAuditing#modifyOnCreate=true. this.lastModifiedBy = this.createdBy; return; } this.createdBy = createdBy; }
@Entity @Data @EqualsAndHashCode(callSuper=true) @EntityListeners(AuditingEntityListener.class) public class Config extends BaseEntity { private static final long serialVersionUID = 1L; private String name, description, value; /** * 创建者 */ @CreatedBy @ManyToOne private User creator; }
@Getter @Setter @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class AuditingEntity extends BaseEntity { @CreatedBy @Column(name = "created_by") private String createdBy; @LastModifiedBy @Column(name = "modified_by") private String modifiedBy; @CreatedDate @Column(name = "created_date") private LocalDateTime createdDate; @LastModifiedDate @Column(name = "modified_date") private LocalDateTime modifiedDate; }
@CreatedBy private String createdBy;
@CreatedBy private User createdBy;
@CreatedBy private String createdBy;
public abstract class AbstractCreatableEntity extends AbstractEntity { @CreatedBy @NotEmpty(groups = { PersistenceOnly.class }) @Column(nullable = false)
@CreatedBy private ID createdById;
@CreatedBy private User createdBy;
@Getter @Setter @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class AbstractAuditableEntity<U, ID> extends AbstractPersistableEntity<ID> implements Serializable { @CreatedDate LocalDate createdDate; @LastModifiedDate LocalDate lastModifiedDate; @CreatedBy @ManyToOne @JoinColumn(name = "created_by") U createdBy; @LastModifiedBy @ManyToOne @JoinColumn(name = "last_modified_by") U lastModifiedBy; }
@CreatedBy @Column(name = "CREATED_BY", nullable = true) private String createdBy;
@CreatedBy @Column(name = "CREATED_BY", nullable = false) private String createdBy;
@Document @Data @Builder @NoArgsConstructor @AllArgsConstructor public class Comment implements Serializable{ @Id private String id; @NotBlank private String content; @CreatedDate @Builder.Default private LocalDateTime createdDate = LocalDateTime.now(); private PostId post; @CreatedBy private Username author; }
@CreatedBy private String userId;
@CreatedBy @Column(name = "create_user_id", length = 32, updatable = false) private String createUserId;
protected Date updatedAt; @CreatedBy protected String createdBy;
@CreatedBy private String createdBy;