Hibernate version: 3.2
Name and version of the database you are using: SQLServer Express
Hi,
I am trying to create an audit history mapping like so in my AuditRecord Mapping file:
Code:
<any id-type="java.lang.Integer" meta-type="java.lang.String"
name="entityAuditRecord" >
<meta-value
class="model.Balance"
value="Balance" />
<column name="ENTITY_NAME" />
<column name="ENTITY_ID" />
</any>
In Balance's Mapping file I have the following:
Code:
<one-to-one name="entityAuditRecord"
class="model.EntityAuditRecord"
/>
(EntityAuditRecord extends the AuditRecord class)
Ideally I would like to be able to call the following code to get the corresponding audit message.
Code:
balance.getEntityAuditRecord().getAuditMessage()
The issue I am having at the moment is that I can't set ENTITY_NAME and ENTITY_ID in the Hibernate interceptor. I created the corresponding fields and getters and setters in the AuditRecord class, however these don't seem to get persisted to the database. I then tried creating a property for each, but Hibernate complained that the column was defined twice. As far as I can tell the correct SQL is generated, however the values are not set.
I have yet to test getting audit messages as above, and would like feedback on this too as I can't find any information for bidirectional <any> mappings.
My next alternative would be to create a BalanceAuditRecord mapping table which gets populated dynamically (by class name) in the interceptor.