Re: [nhusers] Envers FluentConfiguration: Relation to non-audited table

448 views
Skip to first unread message

Atilla İlhan KARTAL

unread,
Apr 10, 2013, 1:33:30 PM4/10/13
to nhu...@googlegroups.com

i am using envers attribute configuration and instead of using fluentconfiguration it is useful attribute configuration for this case. i am on mobile now but when i am on pc i can send a sample code

10 Nis 2013 20:14 tarihinde <aa...@pleasantsolutions.com> yazdı:

In integrating NHibernate.Envers with our framework, I'm trying to determine how to enable auditing on one table but not on a related table.  We're using FluentConfiguration, out of a desire to be as POCO as possible.

I have three classes: AuditParent, AuditChild, and NoAuditChild, where there's a one-to-many from AuditParent to both other classes.  My Envers configuration looks like this:

            var ecfg = new FluentConfiguration();
            ecfg.Audit<AuditParent>()
                .ExcludeRelationData(a => a.NoAuditChildren);
            ecfg.Audit<AuditChild>();

When I run cfg.IntegrateWithEnvers(ecfg), though, I get the following error:

NHibernate.MappingException : An audited relation from NHibernate.Envers.Tests.NetSpecific.UnitTests.CustomLists.AuditParent.NoAuditChildren to a not audited entity NHibernate.Envers.Tests.NetSpecific.UnitTests.CustomLists.NoAuditChild!
   at NHibernate.Envers.Configuration.Metadata.AuditMetadataGenerator.GetReferencedIdMappingData(String entityName, String referencedEntityName, PropertyAuditingData propertyAuditingData, Boolean allowNotAuditedTarget) in AuditMetadataGenerator.cs: line 546
   at NHibernate.Envers.Configuration.Metadata.CollectionMetadataGenerator.addOneToManyAttached(Boolean fakeOneToManyBidirectional) in CollectionMetadataGenerator.cs: line 116
   at NHibernate.Envers.Configuration.Metadata.CollectionMetadataGenerator.AddCollection() in CollectionMetadataGenerator.cs: line 94
...

It looks to me like the code is adding AuditedAttribute(TargetAuditMode = RelationTargetAuditMode.NotAudited) to the property, but somehow this doesn't stop the mapping code from trying to map the relation anyway.  There may be a problem with the if condition in GetReferencedIdMappingData...  I should be able to upload a failing unit test on Bitbucket if desired, unless I'm just doing something wrong with my configuration.

Aaron V. Humphrey
Pleasant Solutions

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+u...@googlegroups.com.
To post to this group, send email to nhu...@googlegroups.com.
Visit this group at http://groups.google.com/group/nhusers?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Roger Kratz

unread,
Apr 10, 2013, 7:00:45 PM4/10/13
to nhu...@googlegroups.com
Using ExcludeRelationData (or RelationTargetAuditMode.NotAudited using Attribute conf) on a bidirectional one-to-many ref currently doesn't work.

I saw you reported...
https://nhibernate.jira.com/browse/NHE-116
Confirmed.



________________________________
Från: nhu...@googlegroups.com [nhu...@googlegroups.com] för aa...@pleasantsolutions.com [aa...@pleasantsolutions.com]
Skickat: den 10 april 2013 18:44
Till: nhu...@googlegroups.com
Ämne: [nhusers] Envers FluentConfiguration: Relation to non-audited table
Reply all
Reply to author
Forward
0 new messages