Your revision entity doesn't have a [RevisionNumber] and/or
[RevisionTimestamp] attribute - my suggestion is below, but I don't
guarantee that it's correct:
- Inherit CustomRevisionEntity from DefaultRevisionEntity
- Remove everything except the custom property(s) you're adding e.g.
UserIdentityId
The following code is an extract from a working system, you probably
want to inherit from DefaultRevisionEntity:
/// <summary>
/// Entity class storing Envers revision information
/// </summary>
[RevisionEntity(typeof(RevisionListener))]
public class RevisionEntity :
DefaultTrackingModifiedEntitiesRevisionEntity
{
/// <summary>
/// User responsible for the revision
/// </summary>
public virtual string UserName { get; set; }
/// <summary>
/// Originating IpAddress for the change
/// </summary>
public virtual string IpAddress { get; set; }
/// <summary>
/// List of entities that changed in the revision
/// </summary>
public virtual ICG.ISet<string> ModifiedEntities { get;
protected set; }
public RevisionEntity()
{
this.ModifiedEntities = new
ICG.HashedSet<string>();
}
}
public class RevisionEntityMap : ClassMapping<RevisionEntity>
{
public RevisionEntityMap()
{
Table("RevisionInfo");
Schema("revisions");
Id(x => x.Id, m =>
{
m.Generator(Generators.Native);
m.Column("Id");
});
// etc
enversConf.SetRevisionEntity<RevisionEntity>(x => x.Id, x =>
x.RevisionDate, new RevisionListener());
From: [email protected] [mailto:[email protected]] On
Behalf Of Jonas Versen
Sent: 23 April 2013 08:57
To: [email protected]
Subject: [nhusers] Trouble logging userid when using Nhibernate Envers
My apologies for cross-posting this here and on Stack Overflow, but I
have a very tight deadline (like always) and was hoping for a quick
response indicating if this is a bug in NHibernate Envers or not.
I'm getting "Only one property may have the attribute [RevisionNumber]!"
when trying to use my own CustomRevisionInformation class. I've tried
setting it up both using Fluentconfiguration (preferred) and using
AttributeConfiguration, Both fails with the same MappingException.
More details can be found on SO
http://stackoverflow.com/questions/16161697/auditing-user-using-nhiberna
te-envers-fluentconfiguration
I'd be very grateful for any feedback.
/Jonas
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.