我在映射一对多关系时遇到此异常。我的映射xml看起来像这样:

<set name="-----" generic="true" inverse="true" cascade="all" lazy="false">
      <key column="Id" />
      <one-to-many class="-----------,---------" />
</set>

而且,

<many-to-one name="------" column="Id" not-null="true" class="---------,-------" />

和例外:

------ Test started: Assembly: ----------.dll ------

TestCase '-------.GetSchema' failed: NHibernate.MappingException : Could not determine type for: Iesi.Collections.Generic.ISet`1[[-----------, --------, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], Iesi.Collections, Version=1.0.1.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4, for columns: NHibernate.Mapping.Column(--------)
   at NHibernate.Mapping.SimpleValue.get_Type()
   at NHibernate.Mapping.SimpleValue.IsValid(IMapping mapping)
   at NHibernate.Mapping.Property.IsValid(IMapping mapping)
   at NHibernate.Mapping.PersistentClass.Validate(IMapping mapping)
   at NHibernate.Mapping.RootClass.Validate(IMapping mapping)
   at NHibernate.Cfg.Configuration.Validate()
   at NHibernate.Cfg.Configuration.BuildSessionFactory()
   at in 
0 passed, 1 failed, 0 skipped, took 4.20 seconds (NUnit 2.5.2).

请告诉我这里发生了什么。 谢谢, 雷迪

编辑:对不起朋友,这是一个错字,我在发布问题后发现了......很奇怪......

有帮助吗?

解决方案

在我的情况下,这不是一个拼写错误,我有一个类 RuleInfo ,其字段为 ActionInfo

我设法通过将 [Serializable] 添加到 ActionInfo 类来解决我的问题。

有趣的是,使用 ActionInfo 时一切正常,即我可以使用单元测试在数据库上对其进行CRUD。

我还可以CRUD RuleInfo ,不用 ActionInfo 字段。添加字段后,出现错误。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top