1 Reply Latest reply on Feb 27, 2012 7:47 AM by Ash McConnell

    Confusion on how to add extra revision info

    Ash McConnell Newbie

      Hi Folks,


      I'm having a little trouble adding username data to revisions using Envers.


      I have managed to get envers to write revision information for one of my entities (to a _AUD table).  I would also like to associate a username with each revision, so we can track who made a particular change.


      I added a Revision Entity like this: -




      public class MyRevisionEntity extends DefaultRevisionEntity {


        private String username;


        public String getUsername() {

          return username;



        public void setUsername(String username) {

          this.username = username;







      and a Revision Listener: -




      public class MyRevisionListener implements RevisionListener {



        public void newRevision(Object revisionEntity) {

          MyRevisionEntity smpRE = (MyRevisionEntity) revisionEntity;


          Object princ = SecurityContextHolder.getContext().getAuthentication().getPrincipal();


          if (princ == null) {



          else {

            SecureMember sm = (SecureMember) princ;









      I expected a record to be created in the MyRevisionEntity table each time a new revision was created.  It seems to just have a single entry.  Have I misunderstood the purpose of the RevisionEntity/Listener or made a mistake in configuration?  The _AUD tables seem to be working as expected by the way.


      Thanks for your help

      All the best,