The following types may not be used as proxies
来源:互联网 发布:三国志11知乎 编辑:程序博客网 时间:2024/04/28 13:11
异常:
The following types may not be used as proxies:
需要改的有两点:
例如: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.
在网上查的资料有三种解决方案,下面转载
1. You can follow the advice of the exception and add "virtual" to all of your properties, and make sure your class is non-sealed.Obviously you'll want to do this if you think you might want to take advantage of the lazy-initializing proxy feature. However, changing your classes may notbe practical or advisable if you have a legacy codebase, or it may just bother you that a "transparent" persistence framework is dictating how you design certain aspects of your value classes. That's where Options 2 and 3 come in. Both of those involve changing back to the old behavior.
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.
在网上查的资料有三种解决方案,下面转载
1. You can follow the advice of the exception and add "virtual" to all of your properties, and make sure your class is non-sealed.Obviously you'll want to do this if you think you might want to take advantage of the lazy-initializing proxy feature. However, changing your classes may notbe practical or advisable if you have a legacy codebase, or it may just bother you that a "transparent" persistence framework is dictating how you design certain aspects of your value classes. That's where Options 2 and 3 come in. Both of those involve changing back to the old behavior.
2. To change the lazy-initialization proxy setting for a specific class, you can add a "lazy='false'" attribute to the <class> mapping element. This might look something like:
<class
name="NorthwindClasses.Category, NorthwindClasses"
table="Categories"
lazy="false"
>
name="NorthwindClasses.Category, NorthwindClasses"
table="Categories"
lazy="false"
>
3. To change the lazy-initialization proxy setting for all classes in a given mapping file, you can add a "default-lazy='false'" attribute to the <hibernate-mapping> element, as follows:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"default-lazy="false">
Unfortunately, Option 3 doesn't really help you much if you do one <class> mapping per <hibernate-mapping> file, a practice which I personally follow and recommend. It's too bad, but there doesn't seem to be any way to set this default in the <nhibernate> global configuration. But if you do happen to have all of your <class>'s in one .hbm.xml file, "default-lazy" can help you out.
- The following types may not be used as proxies 异常
- The following types may not be used as proxies
- 关于NHibernate异常The following types may not be used as proxies
- 2 Which of the following cannot be used as input to the SQL Tuning Advisor? (Choose all that apply.)
- Compilation Error:function 'NAME_IN' may not be used in SQL
- " 'this' may not be used in this context"
- new types may not be defined in a return type
- (NOT CLEAR)Question 22: Which of the following functions of the ifstream class can be used to determine the current position of
- The following control could not be licensed: TXTextControl.TextControl解决方法
- Android The following classes could not be instantiated
- Rendering Problems The following classes could not be found
- 解决方案-Rendering Problems-The following classes could not be instantiated:
- android Rendering Problems :The following classes could not be instantiated
- SQL3169N The FORCEIN option may be used to make the PC/IXF column
- 关于C++中报Error:new types may not be defined in a return type问题
- 编译出错"new types may not be defined in a return"
- codeblocks中Error:new types may not be defined in a return type错误
- new types may not be defined in a return type 排错
- window 应用程序启动监控及把应用程序提权作为服务
- Ubuntu-get使用指南
- 解析UTF8字符串,并截取每个字符到vector(C++代码)
- 2011年小结
- NDK SBNew: Buffer OOM错误问题解决
- The following types may not be used as proxies
- MFC combobox增加显示行数的方法
- 更改Android编译时的默认配置
- Eclipse安装SVN插件
- NHibernate 异常 No persister for 类名
- 设计模式
- wince 下有哪些可以玩的免费游戏软件?
- 自己动手写框架
- 滑动显示首字母的ListView