3 Replies Latest reply on Jun 4, 2010 5:43 PM by klowtherjr

    Envers and InheritanceType.JOINED Question

      I apologize in advance if I've missed the answer to this, but I haven't seen it in searching the discussions or documentation.  I'm using Envers 1.2.1.GA at the moment.

       

      Suppose there are two classes AbstractWidget and RedWidget.  RedWidget extends AbstractWidget, which specifies an InheritanceType.JOINED strategy as there is a separate table for each class.  The table mapped to the RedWidget class has a primary key of RED_WIDGET_ID, while AbstractWidget has a primary key of WIDGET_ID.  I do not and cannot control the database column names.  RedWidget specifies the @PrimaryKeyJoinColumn("RED_WIDGET_ID").  Everything works fine.

       

      When envers is added into the mix, the auditing need only take place on the fields contained in RedWidget.  For the most part this seems like it will work.  I have marked both classes as @Audited and marked all of the fields in the AbstractWidget as @NotAudited (including the primary key).  The problem I'm running into is the RED_WIDGET_AUD table is supposed to contain the primary key of the subclass RED_WIDGET_ID as one of its columns.  Instead envers is trying to insert the parent class' WIDGET_ID column, which doesn't exist, in the generated INSERT statement.  I understand that both values are the same, yet I do not control the column names for the tables.

       

      Is there any way to get envers to use the column name of the primary key of the joined subclass instead of that of the parent class (the parent's primary key is marked as @NotAudited)?  If that is not possible, is there any way to override the column name into which envers inserts a value in the audit table?

       

      Thanks!

       

      Ken