[hibernate-dev] Envers: Mapped-superclasses extended by embeddabables

Gail Badner gbadner at redhat.com
Fri May 16 19:20:10 EDT 2014


Hi Adam,

The relevant issues:
HHH-8908 : Envers: Column of Embedded missing in Audit Table
HHH-9194 : Revert HHH-8908 fix
HHH-9193 : Default audit behavior of a mapped-superclass is inconsistent when extended by an entity vs an embeddable

I created a pull request for reverting HHH-8908 (https://github.com/hibernate/hibernate-orm/pull/742). The fix is reverted for HHH-9194 and I've re-purposed the testcases that were added to HHH-8908 for HHH-9193. I'm still a little fuzzy of the expectations of these tests, so please take a look at the pull request and let me know if anything needs to be changed.

I'm still unsure how on the ways to explicitly enable auditing for a mapped-superclass as a whole or particular fields/methods. Here are some guesses on how I think it should work. Assume the following uses AccessType.FIELD.

In the following, A.b.intValue should be audited; A.b.strValue should not be audited.

@Entity
@Audited
public class A{
    ...
    private B b;
    ...
}

@Embeddable
public class B extends AbstractB {
    private int intValue;
}

@MappedSuperclass
public class AbstractB {
    private String strValue;
}

In the following, both A.b.intValue and A.b.strValue should be audited:

@Entity
@Audited
@AuditOverride( name="b.strValue" )
public class A{
    ...
    private B b;
    ...
}

@Embeddable
public class B extends AbstractB {
    private int intValue;
}

@MappedSuperclass
public class AbstractB {
    private String strValue;
}

In the following, both A.b.intValue and A.b.strValue should be audited:

@Entity
@Audited
public class A{
    ...
    private B b;
    ...
}

@Embeddable
public class B extends AbstractB {
    private int intValue;
}

@MappedSuperclass
@Audited
public class AbstractB {
    private String strValue;
}

In the following, both A.b.intValue and A.b.strValue should be audited. 

@Entity
@Audited
public class A{
    ...
    private B b;
    ...
}

@Embeddable
@AuditOverride( class=AbstractB.class )
public class B extends AbstractB {
    private int intValue;
}

@MappedSuperclass
public class AbstractB {
    private String strValue;
}

What should be the outcome of the following? Should A.b.strValue still be audited even though A.b is explicitly not audited?

@Entity
@Audited
public class A{
    ...
    @NotAudited
    private B b;
    ...
}

@Embeddable
public class B extends AbstractB {
    private int intValue;
}

@MappedSuperclass
@Audited
public class AbstractB {
    private String strValue;
}

Please clarify or correct as necessary. At this point, I'm not sure which of the above cases work. Once the expected behavior is clarified, tests should be added to ensure that envers operates as expected. Jira issues should be added for cases that don't work.

Thanks,
Gail


More information about the hibernate-dev mailing list