4 Replies Latest reply on Nov 12, 2010 5:07 AM by Adam Warski

    Can I audit only a foreign key and not the reffered entity?

    florin13 Newbie

      Hi,

       

         I have 2 entities: Person and Name and a unidirectional one-to-one relationship from Person to Name. The Person object has a reference to a Name object. In the DB the Person table has a FK:Name_Id associating it to the Name table.

       

        I would like to audit the Person entity in such a way that the Person_AUD table can contain a Name_Id column. So I would like to audit the FK too but I don't want to audit the Name entity.

       

      If I audit the Person entity, including the relationship to Name, but I don't audit the name entity I get the following error:

      org.hibernate.MappingException: An audited relation from com.my.Person.name to a not audited entity com.my.Name! Such mapping is possible, but has to be explicitly defined using @Audited(targetAuditMode = NOT_AUDITED).

       

      This makes sense, envers audits entities not tables. But is there a way in which I can also audit the Name_Id column from the Person table in the Person_AUD revision table?