I'm new to NHibernate and am experiencing issues trying to model an IDictionary.
The key of my dicionary is a complex type called 'Identifier' and the corresponding 'value' is of type string e.g. IDictionary<Identifier,string>.
(apologies if the entity name 'Identifier' makes this confusing, its a domain term and I went with it :) )
My mapping is as follows:
<map name="Identifiers" table="ShareClassIdentifier" lazy="false" >
<key>
<column name="ShareClassIdentifier_ShareClassId" />
开发者_Go百科</key>
<composite-index class="Identifier">
<key-property column="ShareClassIdentifier_IdentifierId" name="Id" />
</composite-index>
<element column="ShareClassIdentifier_Value" type="System.String" />
</map>
Which works fine, in the sense that NHibernate creates my dictionary and the values for the keys are populated. However, my Identifier entity isn't being populated. An Identifier entity is created but is missing all its properties (except its Id).
Using NHibernate Profiler, I can see that NHibernate isn't joining on my Identifier table but I cant figure out how to specify this this join in the above mapping?
Thanks in advance
You are mapping Identifier
there as if it were a component with just one property (Id).
If it's an entity, replace the <composite-index>
element with:
<map-key-many-to-many class="Identifier"
column="ShareClassIdentifier_IdentifierId"/>
精彩评论