-1

i'am using fluent Nhibernate and Envers with this setup

var enversConf = new NHibernate.Envers.Configuration.Fluent.FluentConfiguration();

        enversConf.Audit<Segnalazione>()            

        IRevisionListener revListner = services.GetService<IRevisionListener>();
        enversConf.SetRevisionEntity<RevisionEntity>(e => e.Id, e => e.RevisionDate, revListner);
        cfg.SetEnversProperty(ConfigurationKey.AuditTableSuffix, "_LOG");
        cfg.SetEnversProperty(ConfigurationKey.AuditStrategy, typeof(CustomValidityAuditStrategy));

        cfg.IntegrateWithEnvers(enversConf);

i need to change AuditJoinTable naming adding a prefix XXX_

All others table have same prefix and so standard logging table inherits it, only JoinTable hasn't it

i found settings for java version but not for .net one

EDIT: Now i have table with this naming convention:

XXX_Table1
XXX_Table2

main log table are create with _LOG suffix, so i get

XXX_Table1_LOG 
XXX_Table2_LOG 

while

AuditJoinTable are created as

Table1Table2_LOG 

and i need

XXX_Table1Table2_LOG 
gt.guybrush
  • 1,320
  • 3
  • 19
  • 48

2 Answers2

1

I am solving this by adding the name to each join table. Could be more generic but it works.

enversConf.Audit<Segnalazione>()
            .SetTableInfo(ug => ug.Foo, t => t.TableName = "XXX_Segnalazione_Foo")
core
  • 851
  • 1
  • 8
  • 28
0

Do you mean that cfg.SetEnversProperty(ConfigurationKey.AuditTablePrefix, "XXX_") doesn't work? It should.

IEnversNamingStrategy is used to decide names for tables, default this one is used where ConfigurationKey.AuditTablePrefix is used for "default prefix". You can also inject your own impl of this interface if you want to.

Using SetTableInfo overrides this and surely works but if I understand you correctly you don't need to do that in this case.

Roger
  • 1,944
  • 1
  • 11
  • 17
  • AuditTablePrefix set prefix for all log table, i need to customize only AuditJoinTable. i will add example to my question – gt.guybrush Mar 25 '21 at 08:04
  • This comment (that AuditTablePrefix affects all tables incl join tables) and the edit you just did in your org question (that AuditTablePrefix doesn't affect join tables?), doesn't they say different things? Anyhow - use `IEnversNamingStrategy` for more custom naming of your tables. – Roger Mar 25 '21 at 08:51
  • i don't have a prefix setup by envers for all tables, but manually from me in data tables, so audit table inherits it. joinTable does not come from orignale table name and so don't have prefix – gt.guybrush Mar 25 '21 at 09:36
  • Ok, use `IEnversNamingStrategy` then. – Roger Mar 25 '21 at 10:47