Hello,
I'm trying to do something a little out of the ordinary using the <any> tag and <meta-value> tags. I'm working on adding auditing to our system, but not in the traditional sense. In a nutshell, I have a marker interface that if any entity implements, it will automatically be audited every time a new record is created, it's modified, or is deleted. I've already got it working using an Interceptor and the <any> tag.
First, here's what my audit class definition looks like using the <any> tag looks currently looks like:
Code:
<class name="com.blah.audit.Audit" table="Audit">
<id name="id"
column="id">
<generator class="sequence"/>
</id>
<property name="modifiedBy"
column="modified_by"
type="string"
not-null="true"/>
<property name="modifiedOn"
column="modified_on"
type="timestamp"
not-null="true"/>
<property name="auditType"
type="auditType"
column="audit_type"/>
<any name="auditable"
meta-type="string"
id-type="long">
<meta-value value="AuditableObject" class="com.blah.AuditableObject"/>
<meta-value value="AnotherAuditableObject" class="com.blah.AnotherAuditableObject"/>
<column name="auditable_type"/>
<column name="auditable_id"/>
</any>
</class>
Now I don't want to constantly come back and modify the mapping file every time a new object becomes auditable and add a <meta-value> to the <any> tag. This could become very lengthy as we add auditing support to a lot of entities.
So is there some hook that I can plug into when hibernate parses the mapping file that I can use to add new meta-value tags whenever a class it's parsing is identified as being auditable?
I looked through the reference manual and nothing jumped out at me.
Any help would be greatly appreciated.
John