I read this article and am looking for a way to dynamically change the mapping at runtime to bind to another table using a one to many dependency, depending on the value in my parent object.
Here are my mappings
<bag name="Data" mutable="true" > <key> <column name="Log_Link" /> <column name="channel" /> </key> <one-to-many class="Fluent.Entities.Meters.FTIMeterChannelData, Poco" entity-name="30" /> </bag>
as well as
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="property" auto-import="true" default-cascade="none" default-lazy="true"> <class xmlns="urn:nhibernate-mapping-2.2" mutable="true" name="Fluent.Entities.Meters.FTIMeterChannelData, Poco" table="loggerData" entity-name="30"> <composite-id mapped="false" unsaved-value="undefined"> <key-property name="Channel" type="System.Int32"> <column name="channel" /> </key-property> <key-property name="LogLink" type="System.Int32"> <column name="Log_Link" /> </key-property> </composite-id> <property name="Date" type="System.DateTime"> <column name="hhdate" /> </property> </class> <class xmlns="urn:nhibernate-mapping-2.2" mutable="true" name="Fluent.Entities.Meters.FTIMeterChannelData, Poco" table="loggerData10" entity-name="15"> <composite-id mapped="false" unsaved-value="undefined"> <key-property name="Channel" type="System.Int32"> <column name="channel" /> </key-property> <key-property name="LogLink" type="System.Int32"> <column name="Log_Link" /> </key-property> </composite-id> <property name="ReadingType" type="System.Char"> <column name="readingtype" /> </property> </class> </hibernate-mapping>
Now, as the article says, I can change the name of the object using an interceptor.
class LoggerDataInterceptor : EmptyInterceptor { public override string GetEntityName(object entity) { return Convert.ToString("20"); } }
Now the question is doubled.
Firstly, I canβt get this interceptor to work, despite the fact that I announce it at the opening of my session, and secondly, I completely bark, and it never works?
source share