For logging purposes, several tables of my database contain the same four fields:
SysCreatedOn
SysCreatedBy
SysLastUpdatedOn
SysLastUpdatedBy
I have an AuditLog class that contains properties for each of the above values. I also have an IAuditable interface that defines AuditLog as a property.
I'm using an NHibernate Interceptor to populate the values of my AuditLog property (for any business object implementing IAuditable).
I'm finding it cumbersome to have to include the component element & property mappings for each of my business objects implementing IAuditable.
What I would really love is a way to define the component once (in its own mapping file) and somehow reference it in any of the mappings which I know will use it. That way, if I ever decide to add a 5th property I wouldn't have to updated dozens of mapping files, just the one AuditLog class and the one mapping of the component.
Or better still, create a mapping file containing the component with the class name set to IAuditable (no table name) and every time a Business Object implements IAuditable, the mapping file is automatically used.
Is there some way, maybe with some fancy reflection, to setup something like this?
-Mike.
|