分类

链接

2012 年 1 月
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

近期文章

热门标签

新人福利,免费薅羊毛

现在位置:    首页 > .NET > 正文
共享办公室出租
关于NHibernate异常The following types may not be used as proxies
.NET 暂无评论 阅读(3,285)

异常:

 

The following types may not be used as proxies:

NHibernateDemo.DataAccess.DomainObjects.Customer: method get_Name should be virtual

NHibernateDemo.DataAccess.DomainObjects.PurchaseItem: method set_Id should be virtual.....

 

需要改的有两点:

例如:Customer.hbm.xml

 

<?xml version="1.0" encoding="utf-8" ?>

<hibernate-mapping xmlns=" urn:nhibernate-mapping-2.2">

<class name="NHibernateDemo.DataAccess.DomainObjects.Customer, NHibernateDemo.DataAccess" table="Customer" lazy="false">

<id name="Id" type="Int32" unsaved-value="null">

<column name="ID" length="4" sql-type="int" not-null="true" unique="true" />

<generator class="native" />

</id>

<property name="Name" type="String">

<column name="Name" length="30" sql-type="nvarchar" not-null="true"/>

</property>

<bag name="CustomerPurchases" inverse="true" lazy="true" cascade="all-delete-orphan">

<key column="CustomerID"/>

<one-to-many class="NHibernateDemo.DataAccess.DomainObjects.Purchase, NHibernateDemo.DataAccess"/>

</bag>

</class>

</hibernate-mapping>

 

1.未能找到元素“urn:nhibernate-mapping-2.0:hibernate-mapping”的架构信息

把 原来的urn:nhibernate-mapping-2.0改为urn:nhibernate-mapping-2.2

 

2 .在class中添加lazy=false.

============ 欢迎各位老板打赏~ ===========

本文版权归Bruce's Blog所有,转载引用请完整注明以下信息:
本文作者:Bruce
本文地址:关于NHibernate异常The following types may not be used as proxies | Bruce's Blog

发表评论

留言无头像?