Nhibernate一些问题解决方法
解决办法:
一、Test.Model.Person.hbm.xml(2,2): XML validation error: 未能找到元素“urn:nhibernate-mapping-2.0:hibernate-mapping”的架构信息。
将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
网上搜到的三种解决方案:
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 默认为类启用了延迟加载功能
解决方法:
方法1.在映射文件 class 标签中添加 Lazy="false" 属性
例:<class name="Entitys.login, Entitys" table="login" lazy="false">
方法2.为每个实体类的属性成员 添加 “ virtual ” 修饰符;
例:
public virtual int id
{
get { return m_id; }
set { m_id = value; }
}
注:我是在映射文件 class 标签中添加 Lazy="false" 属性解决问题的
问题3。
The dialect was not set. Set the property hibernate.dialect
注:在配置文件里设定Nhibernate的方言即可,如NHibernate.Dialect.OracleDialect,NHibernate.Dialect.MsSql2000Dialect
-----------搞定
问题4.
映射的时候,class name值的问题
class name=“命名空间.类名,项目名”
即class name=“NameSpace.类名,ProjectName”
转载于:https://www.cnblogs.com/umain/archive/2008/08/14/1267544.html
Nhibernate一些问题解决方法相关推荐
- Oracle不能在本地计算机启动,Windows 不能在本地计算机启动 OracleDBConsoleorcl的问题解决方法...
解决步骤如下: 1.开始->运行cmd 2.执行 emctl start dbconsole 输入:C:\Documents and Settings\xcl>emctl start db ...
- IDEA的CPU占用率高问题解决方法
前言:这段时间发现 IDEA 的 CPU 占用率猛涨,时不时就飙升到百分之7.80,使得敲代码的体验感十分不佳,在经过一番查找之后终于解决了问题,在此记录一下 IDEA的CPU占用率高问题解决方法 问 ...
- vs2019 MFC 中 cannot open include file 'afxres.h' 问题解决方法
vs2019 MFC 中 cannot open include file 'afxres.h' 问题解决方法 使用Everything查找afxres.h文件,如果没有everything的,可以到 ...
- IE问题解决方法汇总
1.发送错误报告 [故障现象]在使用IE浏览网页的过程中,出现"Microsoft Internet Explorer遇到问题需要关闭--"的信息提示.此时,如果单击"发 ...
- 我的电脑点不开问题解决方法?
我的电脑点不开问题解决方法? 今天遇到一个问题,就是用鼠标点击任何东西都没什么反应,刚开始想了到底是为什么呢?不过这个问题确实没遇到过,后来想了一段时间,我在想会不会非法关机引起的,后来开始菜 ...
- python php 通信,Python和php通信乱码问题解决方法
Python和php通信乱码问题解决方法 发布于 2014-07-29 22:28:21 | 118 次阅读 | 评论: 0 | 来源: 网友投递 PHP开源脚本语言PHP(外文名: Hypertex ...
- 王者荣耀s22服务器未响应是什么意思,王者荣耀s22资源包升级失败 s22解析包出现问题解决方法...
王者荣耀s22资源包升级失败怎么解决?相信大家都知道王者荣耀S22破晓版本在今日14日正式推出,一时间大量玩家去更新游戏,不过有一小部分玩家出现了更新问题,那就是资源包升级错误,关于这个问题,官方也给 ...
- 织梦php首页老是自动恢复,dede首页网址自动加上index.html问题解决方法
麦慧网提供:dede首页网址自动加上index.html问题解决方法,dede的首页有index.php和index.html,默认的是index.php重定向到index.html,所以访问时,网址 ...
- Java之相对路径找不到文件问题解决方法
Java之相对路径找不到文件问题解决方法 参考文章: (1)Java之相对路径找不到文件问题解决方法 (2)https://www.cnblogs.com/gongxr/p/8862155.html ...
最新文章
- 高文院士:为什么中国的AI发展必须要有开源开放平台?
- python 模拟键盘_Python 模拟键盘输入 | 学步园
- Microsoft Dynamics CRM 2011 JS操作集锦
- java hashmap非线程安全
- python-IO多路复用,select模块
- 神经网络学习之----Hopfield神经网络(代码实现)
- WPF ChromiumWebBrowser 网页背景透明
- 个人空间风格模版php,home.php这个页面风格模板在哪里修改?答案:space_home.html...
- LeetCode —— 面试题 08.12. 八皇后(Python)
- linux系统计算从1加到100之和思路风暴
- 利用计算机诊断ct故障,计算机在CT室工作中的应用及管理
- 王春晖:发展自主知识产权的网安核心技术迫在眉睫
- 高并发情况下修改系统参数
- windows启动winload.exe的数字签名错误问题
- 25个最佳SSH命令
- python导入栈包
- 洛谷 P2706 巧克力 题解
- Eureka自我保护模式——难点重点
- python语法基础#1
- vue使用高德地图api,点击地图标记,弹出弹窗,使用animate让弹窗有动画的加载