Consider the following hibernate configuration:
<class name="Person">
<id name="id" column="personId">
<generator class="native"/>
</id>
<set name="addresses" table="PersonAddress">
<key column="personId"/>
<many-to-many column="addressId"
class="Address"/>
</set>
</class>
<class name="Address">
<id name="id" column="addressId">
<generator class="native"/>
</id>
<set name="people" inverse="true" table="PersonAddress">
<key column="addressId"/>
<many-to-many column="personId"
class="Person"/>
</set>
</class>
Now, these two classs (Person and Address) have an Auditable interface. In our Hibernate AuditInterceptor class (implements Interceptor), we perform some auditing function if the entity is an instanceof Auditable. In short, all of this code works great...
However, there's this PersonAddress table that doesn't get audited because we don't technically have a POJO for it...so we can't check for some "instanceof". Is there any way in the hibernate configuration that we can tell it to Intercept this PersonAddress table? Maybe we need to handle one of the other actions from the Interceptor (like onCollectionUpdate). I'm not sure...
The only other way I can think to force it to Audit is to convert the relationship to a one-to-many from Person to PersonAddress, one-to-many from Address to PersonAddress and create another class element for PersonAddress that does the many-to-one mappings back to Person and Address.
That seems kind of like extra work and I really want to avoid extra work.
Can somebody suggest a better solution?
Thanks!