4 Replies Latest reply on Oct 4, 2011 4:03 AM by nickarls

    Omitting an entity from auditing

    nickarls

      Hi,

       

      I had an entity Foo which was not audited but it was in a relation to an audited entity so I put a

       

      @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED)

       

      on it. Now when I save the Foo entity itself, I see Envers trying to insert into Foo_AUD which kind of defeats the purpose. Any way around this?

       

      (JBoss AS 7, post 7.0.2)

        • 1. Re: Omitting an entity from auditing
          adamw

          That's if you'd have an audited entity having a relation to a non-audited entity. If you simple have a relation in a non-audited entity pointing to an audited one, you don't need anything.

           

          Adam

          • 2. Re: Omitting an entity from auditing
            nickarls

            The problem is I have something like

             

            {code}

            @Audited

            private Bar bar {

              private Foo foo;

            }

            {code}

             

            but I never want Foo audited and I get the "An audited relation from... such as mapping is possible" so I had to stick the annotation on Foo. Now when I persist Foo on its own, Envers thinks I want Foo audited, just looking at the @Audited and not looking at the semantics of it(?)

            • 3. Re: Omitting an entity from auditing
              adamw

              Just put @NotAudited or @Audited(relationTargetMode=NOT_AUDITED) on the field (Foo foo), depending if you want to store the history of what foothe bar was pointing to, or not.

               

              Adam

              • 4. Re: Omitting an entity from auditing
                nickarls

                Hey, that could actually work. I mis-interpreted the error message and put the annotation on the target entity and not the offending relation-field.