原帖http://www.cnblogs.com/luluping/archive/2009/11/17/1604860.html
-
hbm.xmlNHibernate文件中版本号可能引起的问题.
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
此处的2.2代表了NHibernate的版本号,必须与你安装的NHibernate的产品版本号相符.否则的话,举个例子,若为urn:nhibernate-mapping-2.0,则会出现如下错误: Could not find schema information for the element 'urn:nhibernate-mapping-2.0:hibernate-mapping'. 或是:"NHibernate.Cfg.Environment的类型初始值设定项引发异常". -
在对照类中如果属性没有加virtual关键字,可能报
NHibernate.InvalidProxyTypeException: The following types may not be used as proxies:
Model.FriendLink: method set_Description should be virtual
Model.Type: method get_TypeName should be virtual.....
这是一种解决方案是给属性加上virtual关键字,另一种解决方法是在映射文件中加入default-lazy="false". -
映射文件没有将属性设为"嵌入的资源"引起的错误.
这个是我最常忽略的,如果忽略了它,可能会报比较多的错误,