In our SOA application we have several customers’ data in the same database and in the same tables.
To control access, we have a column that describes this relationship. This column isn’t represented in the domain model, however. I know about query only properties – so, for querying – it is working perfectly.
However, how do I write to this column when saving new rows/entities?
Code:
public class Customer
{
public virtual long Id{get;private set;}
public virtual string AccountNumber{get;set;}
}
Mapping:
<class Name="Customer">
<id name="Id">
<generator class="native"/>
</id>
<property name="AccountNumber"/>
<property name="Partition" access="noop" not-null="true"/>
</class>
I’m not sure to understand from where the value that should be inserted will come from if not set when creating entities (assuming they would provide the appropriate attribute of course) but…
One option would be to use an
IInterceptorto alter the SQL duringOnPrepareStatementand add whatever you want in case of INSERT.And apply your interceptor either at the session level or globally.
Reference