java - How do I create custom field to store user credentials in REVINFO table -


we using hibernate-envers , having *_aud table stores historical state of entities. there global revinfo table contains revision number, timestamp.

i need add user field in revinfo table. how add "user" field in revinfo table?

you can create custom revisioninfo entity. custom revisions entity must have integer-valued unique property (preferably primary id) annotated {@link revisionnumber} , long-valued property annotated {@link revisiontimestamp}.

the {@link defaultrevisionentity} has 2 fields, may extend it, may write own revision entity scratch. in case revision entity may following:

@entity @revisionentity() public class revisionsinfo extends defaultrevisionentity {    private long userid;    public long getuserid() { return userid; }    public void setuserid(final long uid) { this.userid = uid; }  } 

in addition can give custom revisionlistener other special needs . see following example:

public class revisionlistener implements org.hibernate.envers.revisionlistener {     /**      * {@inheritdoc}      */     public void newrevision(final object revisioninfo)     {         // updateinfo info here if required     } } 

the custom revisionlistener can provided argument revisionentity annotation.

@revisionentity(revisionlistener.class) 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -