日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Nhibernate一些问题解决方法

發(fā)布時間:2025/3/16 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Nhibernate一些问题解决方法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
問題1.未能找到元素“urn:nhibernate-mapping-2.0:hibernate-mapping”的架構(gòu)信息。 file:///c:/inetpub/wwwroot/WebApplication1/bin/Course.hbm.xml, (2, 2)處發(fā)生了錯誤。
解決辦法:
一、Test.Model.Person.hbm.xml(2,2): XML validation error: 未能找到元素“urn:nhibernate-mapping-2.0:hibernate-mapping”的架構(gòu)信息。

????? 將2.0改為2.2

二、 The following types may not be used as proxies:
??????? Test.Model.Person: method set_Id should be virtual
??????? Test.Model.Person: method get_Name should be virtual
??????? Test.Model.Person: method set_Name should be virtual
??????? Test.Model.Person: method get_Id should be virtual

??????? 類配置文件中Class的Lazy改為false
??????? 網(wǎng)上搜到的三種解決方案:
??????? 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 not be 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"
>??????? 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.
注:我是修改2.0為2.2解決問題的

問題2.
The following types may not be used as proxies:
Entitys.login: method get_Upwd should be virtual
Entitys.login: method get_id should be virtual
Entitys.login: method get_Uname should be virtual
Entitys.login: method set_Uname should be virtual
Entitys.login: method get_LastTime should be virtual
Entitys.login: method set_Upwd should be virtual
Entitys.login: method set_id should be virtual
Entitys.login: method set_LastTime should be virtual

----------------------------------------------------------------------------

引起問題的原因:

NHibernate 1.2 默認(rèn)為類啟用了延遲加載功能

解決方法:

方法1.在映射文件 class 標(biāo)簽中添加 Lazy="false" 屬性

例:<class name="Entitys.login, Entitys" table="login" lazy="false">

方法2.為每個實(shí)體類的屬性成員 添加 “ virtual ” 修飾符;

例:? ?

????? public virtual? int id
????? {
???????? get {? return m_id; }
???????? set {? m_id = value; }
????? }
注:我是在映射文件 class 標(biāo)簽中添加 Lazy="false" 屬性解決問題的


問題3。
The dialect was not set. Set the property hibernate.dialect
注:在配置文件里設(shè)定Nhibernate的方言即可,如NHibernate.Dialect.OracleDialect,NHibernate.Dialect.MsSql2000Dialect
-----------搞定
問題4.
映射的時候,class name值的問題
class name=“命名空間.類名,項(xiàng)目名”
即class name=“NameSpace.類名,ProjectName”

轉(zhuǎn)載于:https://www.cnblogs.com/umain/archive/2008/08/14/1267544.html

總結(jié)

以上是生活随笔為你收集整理的Nhibernate一些问题解决方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。