下面的文章转载于http://hi.baidu.com/zsea/blog/item/7d999e3d8a54c203baa1678d.html

一、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.

转载于:https://blog.51cto.com/jasonjn/1283105

The following types may not be used as proxies 异常处理办法相关推荐

  1. NHibernate初学体验记

    NHibernate 是一个基于.Net 的针对关系型数据库的对象持久化类库.NHibernate 来源于优秀的基于Java的关系型持久化工具Hibernate.NHibernate持久化你的.Net ...

  2. [NHibernate]基本配置与测试

    目录 写在前面 nhibernate文档 搭建项目 映射文件 持久化类 辅助类 数据库设计与连接配置 测试 总结 写在前面 一年前刚来这家公司,发现项目中使用的ORM是Nhibernate,这个之前确 ...

  3. NHibernate配置引发的异常

    NHibernate.Cfg.Configuration"的类型初始值设定项引发异常 .添加引用 log4net.dll  Iesi.Collections.dll NHibernate.d ...

  4. NHibernate应用二:第一个NHibernate程序

    当前期工作都准备完成后,将开始NHibernate的学习过程,而在第一个NHibernate程序中,将实现通过NHibernate根据客户编号对客户表进行单条记录的查询示例.该示例中,我们将按以下几部 ...

  5. Nhibernate一些问题解决方法

    问题1.未能找到元素"urn:nhibernate-mapping-2.0:hibernate-mapping"的架构信息. file:///c:/inetpub/wwwroot/ ...

  6. NHibernate错误集锦及配置技巧

    前一段时间在学习NHibernate的时候,被那些配置弄得糊里糊涂,有一些很细微的地方不知道错在哪里,花了很多的时间去寻找,最后才调试通过,这里我就把遇到错误的地方以及怎么解决这些错误的方法贴出来,至 ...

  7. NHibernate 异常及解决办法(长期添加中)

    Mapping 错误: 1) Could not determine type for:Namespance.Class,AssemblyName, for columns: NHibernate.M ...

  8. Speerio Skinergy 'Image' is ambiguous 错误

    使用BeyondCSS皮肤时报错: Could Not Load Skin: /Portals/0/Skins/beyondcss/1column_speerio.ascx Error: E:&quo ...

  9. NHibernate入门实例

    转:http://www.cnblogs.com/huhai121/p/3955755.html NHibernate应用一:环境准备 本章将介绍整个开发环境所需开发和数据库工具,以及数据库设计,后续 ...

最新文章

  1. MapReduce: 提高MapReduce性能的七点建议【译】
  2. oracle sql判断相等,Oracle PL/SQL判断两个字段相等或不等问题
  3. Angular依赖注入机制的一个错误消息:Error Cannot instantiate cyclic dependency!
  4. mqtt如何判断设备离线_反渗透纯水设备膜元件如何离线清洗?
  5. lucene中write.lock索引锁机制的原理
  6. .net core 获取binary 文件_Linux操作系统文件目录
  7. 安装Labview2012 “labview 2012 未定义必须的 NIPathsDir属性 maxAFWDIR”
  8. ESXi添加第三方驱动
  9. ScrollView中布局不能充满ScrollView的问题
  10. 逐步揭示makop.mkp勒索病毒中毒防范恢复解密
  11. Spring学习:通过黎活明视频1
  12. html中三角函数表示什么,三角函数的化一公式
  13. 《麦肯锡结构化战略思维》:4大原则 5个步骤,快速了解一个行业
  14. 华为鸿蒙os操作系统有pc版,华为开源操作系统 鸿蒙OS 升级版曝光,打通PC等一大批硬件...
  15. ios9遇到 App Transport Security has blocked a cleartext HTTP(http://) resource load 错误
  16. 阿里云吴翰清:从技术人转型做产品经理是一种什么样的体验
  17. java 实现仿word2007字数统计功能
  18. Python可视化库——plotnine学习和基本使用(二):theme工具库的介绍
  19. Kubernetes 单节点安装Clickhouse
  20. 感恩工作平台心得体会_感恩工作心得体会范文3篇

热门文章

  1. 谷歌 Nest 和 Fitbit 漏洞奖励翻番
  2. NSA和CISA联合发布《5G云基础设施安全保护指南》
  3. OpenEDR:安全厂商Comodo 开源 EDR 解决方案
  4. Hey! 首先祝贺 SpaceX 发射成功,其次我黑了 NASA 某IT 承包商网络哟~
  5. 突然有点想和你唠嗑了~
  6. 杨国勋:云计算颠覆现有市场和产业格局
  7. Java内嵌Groovy脚本引擎进行业务规则剥离(一)
  8. MDT2012+ADK8.0+WDS部署Windows客户端(一)部署概念和方法论
  9. 创建基于存储过程的数据块
  10. Accerlerated c++ 答案