3 Replies Latest reply on Apr 2, 2013 4:16 PM by Adam Warski

    How to enable/disable audit on a single property at runtime?

    Bolek Kulbabinski Newbie

      Hello,

       

      I need to implement a feature that requires turning audit on/off for single properties at runtime. In other words, I'd like to simulate adding/deleting @NotAudited annotation for entity fields.

      I assume that database tables are capable of storing every property. When audit for a particular property is turned off then a) changes in this property do not trigger audit event and b) when an audit event is triggered for the entity, envers should write nulls for not audited properties.

       

      I was browsing through the code to find out how such feature can be implemented and the only reasonable idea I have so far is to hack into AuditConfiguration after it's constructed and before it's used. If I swap ExtendedPropertyMapper for every entity I'm interested in with my own implementations that allow changes at runtime (and properly synchronize them) it seems to be working as expected.

       

      Are there any potential pitfalls in my idea? Is there any cleaner way to do this? If not, would you consider a feature request of allowing to provide user implementations of MultiPropertyMappers (or maybe whole EntityConfiguration) during configuration construction?

       

      Best,

      Bolek