In my project, I have an entity - let's say PurchaseOrder. In order to support the persistence of purchase orders, I have my nhib mappings and db tables created - and everything works fine.
Now, in order to support security requirements, i need to have all purchase orders associated with a system user, which is maintained in a Users database tables and associated via a FK on the PurchaseOrders table. I don't want to create a mapping element for user on PurchaseOrder becuase User doesn't really take part in defining PurchaseOrder. However, I need the owning User specified in the database.
Is there a way to do this kind of persistence in NHibernate?
My current solution is to create an interceptor and associate it with a session (and pass the session to the interceptor) - then on the PostFlush call, get the connection from the session and execute a SQL update statement passing the ID of the user object that exists in context.
Any thoughts on the subject are greatly appreciated!
TIA,
_howard
|