spring-projects / spring-projects/spring-data-commons
AuditorAware#getCurrentAuditor called for Entities only marked CreatedAt [DATACMNS-1404]
Open
@odrotbohm is already working on this.
Since Dec 30, 2020.
in: core
status: feedback-provided
type: enhancement
- Dominant language
- Java
- Stars
- 838
- Forks
- 730
- PR merge metrics
- No merged PRs in 30d
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.