spring-data-commons icon indicating copy to clipboard operation
spring-data-commons copied to clipboard

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

Open spring-projects-issues opened this issue 7 years ago • 4 comments

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)

spring-projects-issues avatar Aug 17 '16 14:08 spring-projects-issues

bump. This feature would have been really useful in a refactoring task i am currently working on.

msndk avatar Mar 03 '21 19:03 msndk

Bump

AlexandreCassagne avatar Jun 08 '21 19:06 AlexandreCassagne

See branch https://github.com/spring-projects/spring-data-commons/tree/issue/DATACMNS-1269.

mp911de avatar Dec 09 '21 10:12 mp911de

Is there any chance that branch which is solving this issue will be merged? I would appreciate that..

m-horejsi avatar Sep 29 '22 13:09 m-horejsi