将NHibernate从2.1.2升级到3.3.1后,在尝试使用Class.ClassDetails字典时,我经常在NHibernate.dll中得到StackOverflowException(例如,获取ClassDetails中的项目数)。我猜这是与延迟加载有关的东西。当我调试它时,我经常在ClassDetails字典中看到如下内容: {NHibernate.Collection.Generic.PersistentGenericMap} ,没有任何数据。
你能告诉我出了什么问题吗?
映射:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false" namespace="SomeNamespace" assembly="SomeAssembly">
<class name="Class,ClassNamespace" table="Class" lazy="false">
<composite-id access="field">
<key-property name="DateTime" column="DateTime" type="Timestamp"/>
<key-property name="Key" column="Key" type="Int32" />
</composite-id>
<property column="Column" type="Int32" name="Column" not-null="true" />
<map name="ClassDetails" table="ClassDetails" lazy="false" >
<key>
<column name="DateTime"/>
<column name="Key"/>
</key>
<index column="Parameter" type="ParameterEnum"/>
<composite-element class="CompositeElement">
<property name="SomeProperty1" column="SomeProperty1" type="Int32"/>
<property name="SomeProperty2" column="SomeProperty2" type="Double"/>
</composite-element>
</map>
</class>
</hibernate-mapping>
代码:
[Serializable]
public class Class
{
...
public Class()
{
ClassDetails = new Dictionary<ParameterEnum, CompositeElement>();
}
public IDictionary<ParameterEnum, CompositeElement> ClassDetails { get; set; }
}