[Nhibernate.Envers] [1.6 GA] property auditing check

76 views
Skip to first unread message

kriebb

unread,
Oct 29, 2013, 10:06:25 AM10/29/13
to nhu...@googlegroups.com
Hi,

We've setup the auditing on property level.
Everything works except some small stuff.

The most important thing first:

We are tracking on property bases,  also with the flag if the property has changed. We are tracking now 7 property's.

The thing is, we even got updates in the table, even if there is no changes detected.
Another entity is updated tough.

We won't want that information in our tables.
If nothing of those properties has changed, we are not interested in the information.

Any tips/hints where I can look for or can override this behavior?

Thanks,


Roger Kratz

unread,
Oct 29, 2013, 10:16:43 AM10/29/13
to nhu...@googlegroups.com

Can you show us some simple mapping + code?

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Kristof Riebbels

unread,
Oct 29, 2013, 10:43:42 AM10/29/13
to nhu...@googlegroups.com
Something like this?
What I see here: is that my valueobject is not in the table... That 's another issue.

----

public class Product:RootEntity<Guid>
{
        private ProductInitiatorUnity productInitiatorUnity;

        public virtual ProductInitiatorUnity ProductInitiatorUnity
        {
            get { return productInitiatorUnity ?? new ProductInitiatorUnity(); }
        }

        [Audited(WithModifiedFlag = true)]
        public virtual string ArticleNumber { get; protected set; }

        [Audited]
        public virtual string LastChangedBy { get; protected set; }

        [Audited]
        public virtual DateTime LastChangedOn { get; protected set; }

        [Audited(WithModifiedFlag = true)]
        public virtual IParameter PickMethod { get; protected set; }

        [Audited(WithModifiedFlag = true)]
        public virtual IParameter ReceivingCode { get; protected set; }
}

public class ReceivingCode: Parameter
{
        [Audited]
        public override string Code
        {
            get
            {
                return base.Code;
            }
            protected set
            {
                base.Code = value;
            }
        }
        [Audited]
        public override string LastChangedBy
        {
            get
            {
                return base.LastChangedBy;
            }
            protected set
            {
                base.LastChangedBy = value;
            }
        }
        [Audited]
        public override System.DateTime LastChangedOn
        {
            get
            {
                return base.LastChangedOn;
            }
            protected set
            {
                base.LastChangedOn = value;
            }
        }
}
public class PickMethod: Parameter
{
        [Audited]
        public override string Code
        {
            get
            {
                return base.Code;
            }
            protected set
            {
                base.Code = value;
            }
        }
        [Audited]
        public override string LastChangedBy
        {
            get
            {
                return base.LastChangedBy;
            }
            protected set
            {
                base.LastChangedBy = value;
            }
        }
        [Audited]
        public override System.DateTime LastChangedOn
        {
            get
            {
                return base.LastChangedOn;
            }
            protected set
            {
                base.LastChangedOn = value;
            }
        }
}

public class ProductInitiatorUnity : ValueObject
    {

        [Audited(WithModifiedFlag = true)]
        public virtual InitiatorUnity InitiatorUnity { get; protected set; }

        [Audited(WithModifiedFlag = true)]
        public virtual InitiatorUnity WmsUnity { get; protected set; }

        [Audited(WithModifiedFlag = true)]
        public virtual int InitiatorQuantity { get; protected set; }

        [Audited(WithModifiedFlag = true)]
        public virtual int WmsQuantity { get; protected set; }

        protected internal ProductInitiatorUnity()
        {
        }

        protected internal ProductInitiatorUnity(InitiatorUnity initiatorUnity, int initiatorQuantity, InitiatorUnity wmsUnity, int wmsQuantiy)
        {
            InitiatorUnity = initiatorUnity;
            InitiatorQuantity = initiatorQuantity;
            WmsUnity = wmsUnity;
            WmsQuantity = wmsQuantiy;
        }
    }

Product.hbm.xml

<class name="Pdc.Erp.Domain.ProductManagement.Product" table="Product" dynamic-update="true" >
    <cache usage="read-write" include="all"/>
<id name="Id" column="id">
 <generator class="guid.comb" />
</id>
    <version name="Version" column="ver" type="Int64" />
    <property name="ArticleNumber" column="article_number" length="20" not-null="true" unique-key="IX_Initiator_ArticleNumber" />
<many-to-one name="ReceivingCode" class="Pdc.Erp.Domain.ProductManagement.Parameters.ReceivingCode, Pdc.Erp.Domain.Core" column="receiving_code_id" not-null="true" foreign-key="FK_Product_ReceivingCode"/>
<many-to-one name="PickMethod" class="Pdc.Erp.Domain.ProductManagement.Parameters.PickMethod, Pdc.Erp.Domain.Core" column="pick_method_id" not-null="true" foreign-key="FK_Product_PickMethod"/>


    <component name="ProductInitiatorUnity" class="Pdc.Erp.Domain.ProductManagement.ProductInitiatorUnity" access="nosetter.camelcase">
      <many-to-one name="InitiatorUnity" column="initiator_unity_id" class="Pdc.Erp.Domain.ProductManagement.Parameters.InitiatorUnity" not-null="false" foreign-key="FK_Product_InitiatorUnity" />
      <property name="InitiatorQuantity" column="initiator_unity_quantity" />
      <many-to-one name="WmsUnity" column="initiator_unity_wms_id" class="Pdc.Erp.Domain.ProductManagement.Parameters.InitiatorUnity" not-null="false" foreign-key="FK_Product_InitiatorUnity_Wms" />
      <property name="WmsQuantity" column="initiator_unity_wms_quantity" />
      
    </component>
<property name="LastChangedBy" column="modifier" length="100" not-null="true" />
<property name="LastChangedOn" column="modified" not-null="true" />
</>


Generated sql:
CREATE TABLE [dbo].[Product_AUD](
[id] [uniqueidentifier] NOT NULL,
[REV] [int] NOT NULL,
[REVTYPE] [tinyint] NOT NULL,
[article_number] [nvarchar](20) NULL,
[ArticleNumber_MOD] [bit] NULL,
[modifier] [nvarchar](100) NULL,
[modified] [datetime] NULL,
[receiving_code_id] [uniqueidentifier] NULL,
[ReceivingCode_MOD] [bit] NULL,
[pick_method_id] [uniqueidentifier] NULL,
[PickMethod_MOD] [bit] NULL,
 CONSTRAINT [PK_Product_AUD] PRIMARY KEY CLUSTERED 
(
[id] ASC,
[REV] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [DATA]
) ON [DATA]




2013/10/29 Roger Kratz <Roger...@teleopti.com>

--
You received this message because you are subscribed to a topic in the Google Groups "nhusers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nhusers/lDQxk56fUh0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nhusers+u...@googlegroups.com.

Roger Kratz

unread,
Oct 29, 2013, 11:22:59 AM10/29/13
to nhu...@googlegroups.com

I don’t understand this I’m afraid

<< 

The thing is, we even got updates in the table, even if there is no changes detected.
Another entity is updated tough.

>> 

What entity are you changing? What entity do you get audit records for?

Kristof Riebbels

unread,
Oct 29, 2013, 11:35:23 AM10/29/13
to nhu...@googlegroups.com
I was afraid of that it was to difficult if you are not in our business logic :-)

I'm going to write a unit test and reproduce it.
It will make the discussion more easier.

But, in order to try to answer your question and to create some clarification

* What is happening?
1 - We get the product. 
2 - An entity 'sequence' linked (many-to-one) to this product is updated.
3 - Nothing is updated in product (also visible in sql profiler: No update statement for product has been launched)

* What is audited?
Some properties of product. (described in previous posts)

* What is not audited?
Entity Sequence is not audited. 

* What is the problem?
None of the properties of product have been changed. Where there is modification flag, it also indicates nothing has been changed.

Tomorrow, i'll post a zip with a small project... try to reproduce...




2013/10/29 Kristof Riebbels <kri...@riebbels.be>

Roger Kratz

unread,
Oct 29, 2013, 11:41:39 AM10/29/13
to nhu...@googlegroups.com

If possible, please pull latest envers code from here

https://bitbucket.org/RogerKratz/nhibernate.envers

and create a small (nunit) test describing your issue.

 

Thanks

Roger

Reply all
Reply to author
Forward
0 new messages