I have a one-to-many association between class A and class C, class C is derived from class B. Class A is Audited, class C is not.
B and C are in one table (strategy = InheritanceType.SINGLE_TABLE), with a discrimator in a column named "type". There are several other classes derived from B.
Class A has a member "allMyC" of type Set<C>, which holds the association. As C is not audited, this member of A is marked with @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED). Furthermore, as I want only the Cs, no other subclasses of B, this member is also marked with @Where(clause = "TYPE = 'TypeC'").
The audit-table for the relation is @AuditJoinTable(name = "A_C_AUD")
So far so good.
Now when I have an older (audited) revision of class A and try to access allMyC of this revision, the generated sql reads like:
acaud0_.TYPE = 'TypeC'
acaud2_.TYPE = 'TypeC'
My problem is in the bold lines:
There the SQL tries to read a column "TYPE" in the auditing table of the association (which doesn't exist, there's only a "TYPE" column in the table of C), thus producing an sql Error .
When (for test purposes) I leave out the @Where(clause = "TYPE = 'TypeC'") annotation of allMyC, the generated SQl is correct (it's just the same as above, without the boldly marked lines).
What can I do when I want to keep the where-clause? I'm using hibernate envers 4.2.4.
Any hints appreciated.
Without the @Where(clause = "TYPE = 'TypeC'") - annotation the sql in the 'historical' scenario is correct.
But is it no valid usage to combine these annotations?