spring-projects / spring-projects/spring-data-commons

Allow having multiple AuditorAware(s) [DATACMNS-894]

Open
#1,352 6 comments 3 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 30, 2020.

type: enhancement
Dominant language
Java
Stars
838
Forks
730
PR merge metrics
No merged PRs in 30d

Description

Andrei Ivanov opened DATACMNS-894 and commented

Trying to use the auditing feature in a multi-module project I've reached a limit.

  • module A
public class User implements Serializable {
}
@EntityListeners(AuditingEntityListener.class)
public class Project implements Serializable {
	@CreatedBy
	private User createdBy;
}
public class UserAuditor implements AuditorAware<User> {
}
  • module B
public class Person implements Serializable {
}
@EntityListeners(AuditingEntityListener.class)
public class SiteAccessRequest implements Serializable {
	@LastModifiedBy
	private Person managedBy;
}

public class PersonAuditor implements AuditorAware<Person> {
}

The problem seems to be that I can only use only one AuditorAware instance.
I think it would be nice to be able to have something like the JpaContext to be able to find the proper auditor for a certain type.

public interface AuditorContext {
    AuditorAware<?> getAuditorAwareByManagedType(Class<?> managedType);
}

Affects: 1.12.2 (Hopper SR2)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.