Skip to content

AuditorAware#getCurrentAuditor called for Entities only marked CreatedAt [DATACMNS-1404] #1839

Open
@spring-projects-issues

Description

@spring-projects-issues

Yuki Yoshida opened DATACMNS-1404 and commented

When we have below two entities.

 

@Entity
@EntityListeners(AuditingEntityListener.class)
public class EntityWithCreatedBy { 
  @Id @GeneratedValue private Integer id;

  @ManyToOne(fetch = FetchType.LAZY)
  @CreatedBy 
  private User createdBy;
}

 

@Entity
@EntityListeners(AuditingEntityListener.class)
public class EntityWithOnlyCreatedAt {

  @Id
  @GeneratedValue
  private Integer id;

  @CreatedDate
  private LocalDateTime createdDate;
}

And try to save them, then org.springframework.data.domain.AuditorAware#getCurrentAuditor was called for both of them.

 

It would be nice when we save entity that does not have @CreatedBy or @LastModifiedBy,

AuditorAware#getCurrentAuditor stop being called.

 

I attached reproduction project (by spring-data-jpa) to Reference URL.

 


Affects: 2.0.10 (Kay SR10)

Reference URL: https://github.com/sis-yoshiday/spring-data-auditing-issue

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions