1 package de.spring.example.persistence.domain.audit;
3 import org.hibernate.envers.RevisionListener;
5 import de.spring.example.context.UsernameThreadContext;
7 public class MyCustomRevisionListener implements RevisionListener {
9 protected MyCustomRevisionListener() {
14 public void newRevision(Object revisionEntity) {
15 MyCustomRevision myCustomRevision = (MyCustomRevision) revisionEntity;
17 final String username = getSafeUsername();
18 myCustomRevision.setUsername(username);
22 private String getSafeUsername() {
23 String userName = UsernameThreadContext.getUsername();
25 if (userName == null) {