2

I am using Spring Data JPA in an application in which all entity objects need auditing. I know that I can have each either implement Auditable or extend AbstractAuditable, but my problem is coming with the overall auditing implementation.

The example on the Spring Data JPA reference pages seems to indicate that you need an AuditableAware bean for each entity. Is there any way to avoid this extra code and handle it in one place or through one configuration?

ilana
  • 91
  • 1
  • 1
  • 3
  • Asking the question clarified it for me. If anybody else has the same question, you only need one AuditorAware bean in your application. It is tied in through whatever authentication method you are using. (Can't answer my own question yet because I'm too new, but figured i'd put it in comments =)) – ilana Jul 29 '11 at 12:56

1 Answers1

1

The generic parameter of AuditorAware is not the entity you want to capture the auditing information for but rather the creating/modifying one. So it will typically be the user currently logged in or the like.

Oliver Drotbohm
  • 80,157
  • 18
  • 225
  • 211