@NotAudited and @Audited(targetAuditMode = RelationTargetAuditMode.NOT_AUDITED) not working with OneToMany mapping on a join table. The Join table has an association with 2 different tables and one of them is Auditable. This is a legacy code and has both Annotation and XML-based configuration, Table A and C have XML configurations.
Mapping of Table A:
@Audited
Class A{
int aid;
@NotAudited
List<B> b;
}
XML configuration of Table A:
<set name="b" table="B" lazy="true" inverse="true" cascade="all, delete-orphan" fetch="select">
<key column="aid" not-null="true"/>
<one-to-many class="B"/>
</set>
Mapping of Join Table B:
@Entity
Class B{
@Id
int bid;
@ManyToOne
@JoinColumn(name = "aid", referencedColumnName = "aid")
A a;
@OneToOne
@JoinColumn(name = "cid", referencedColumnName = "cid")
C c;
}
Mapping of Table C:
Class C{
int cid
B b;
}
XML configuration of Table C:
<one-to-one name="b" property-ref="c" class="B" cascade="all"/>
I see the following message when the application is getting up.
An audited relation from A.b to a not audited entity B
If I put @Audited on Table B then I see query exception table B_aud does not exist.
How can I fix this?