`

NHibernate 错误集合

    博客分类:
  • .net
阅读更多


(1)、Nhibernate错误”No persister for ”

          Nhibernate错误”No persister for <entity name>”

         例如:”No persister for DomainModel.Entities.User”

    1.检查hibernate.cfg.xml是否配置mapping 如:<mapping                                 assembly="”DomainModel”/">

    2.检查User.hbm.xml文件属性“生成操作”的值,从“内容”修改为“嵌入的资源”


(2)、Could not find the dialect in the configuration这个错误,

     这是数据库配置问题

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

    换成

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

(3)、The ProxyFactoryFactory was not configured 报错

     因为没有引用上面那个配置中的工厂类 所以在引用下             Required_For_LazyLoading文件夹下的 LinFu下的NHibernate.ByteCode.LinFu.dll 当然也可以用 Castle 那要改下配置</hibernate-mapping></hibernate-mapping></mapping></entity>

(4)、Could not compile the mapping document

 解决办法:

  调试查看到InnerText为,不应该为<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">,然后我把改为

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">后,此问题解决.


(5)、NHibernate.InvalidProxyTypeException

        The following types may not be used as proxies: TestCleanSnow.BjkptOaxtCleanupsnow: method set_IsDeleted should be virtual TestCleanSnow.BjkptOaxtCleanupsnow: method set_IsChanged should be virtual TestCleanSnow.BjkptOaxtCleanupsnow: method Clone should be virtual TestCleanSnow.BjkptOaxtCleanupsnow: method get_IsChanged should be virtual TestCleanSnow.BjkptOaxtCleanupsnow: method get_IsDeleted should be virtual

解决办法: 在XML的 <class name="TestCleanSnow.BjkptOaxtCleanupsnow,TestCleanSnow" table="B_JKPT_OAXT_CLEANUPSNOW"> 添加  lazy="false" .

(6)、在执行 session.Save(cs);

时,出现could not get next sequence value[SQL: SQL not available] Nhibernate



解决办法:

把相应XML的

 <generator class="native" /> 改为 <generator class="assigned" />

以上我做Oracle时出现的错误,操作sqlserver的时候应该为 <generator class="native" />.



(7)、转载与: 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.





0
0
分享到:
评论

相关推荐

    nhibernate 源码nhibernate 源码

    nhibernate 源码nhibernate 源码nhibernate 源码nhibernate 源码

    NHibernate 资料集合

    而NHibernate,顾名思义,如同NUnit,NAnt一样,是基于.Net的Hibernate实现。  NHibernate 是一个基于.Net 的针对关系型数据库的对象持久化类库。Nhibernate 来源于非常优秀的基于Java的Hibernate 关系型持久化工具...

    nhibernate

    nhibernate c#nhibernate c#nhibernate c#nhibernate c#nhibernate c#nhibernate c#nhibernate c#

    Fluent nHibernate

    Fluent nHibernate,简化nHibernate工作量的好工具。 nHibernate相信用C#跟数据库打交道的多少知道一些,用过nHibernate的对其中nHibernate的XML配置文件的繁杂应该深有印象。Fluent nHibernate就是为简化nHibernate...

    NHibernate2.0中文文档

    NHibernate2.0中文文档 NHibernate2.0中文文档 NHibernate2.0中文文档

    NHibernate-2.1.2.GA-bin NHibernate框架

    使用与.net开发的NHibernate框架,这个版本是比较老,但是比较经典的。 我也是使用这个来在.net开发的。给大家共享一下。

    NHibernate.JetDriver(基于NHibernate 3.1)

    让NHibernate支持Access数据库的驱动程序,源自Hibernate官方,但官方早不支持了(已从NHibernate主类库剔除),这个是基于NHibernate 3.1.0.4000的,需要NHibernate其他版本的话,请打开解决方案引入不同版本的...

    NHibernate+Oracle NHibernate+MySql Demo

    实现NHibernate+Oracle 与NHibernate+MySql 的连接,以及增删改查的初步使用

    Nhibernate3.0

    最新的3.0版本,Welcome to NHibernate! -------------------------------------------------------------------------------- NHibernate is a .NET based object persistence library for relational databases....

    Nhibernate从入门到精通

    NHibernate 入门之旅教程 PDF版,写这个小书也算是对自己学习NHibernate的一个总结吧。再次向对NHibernate陌生的朋友介绍一下NHibernate,它是一个面向.NET 环境的对象/关系数据库映射工具。用来把对象映射到基于SQL...

    NHibernate

    NHibernate 初学者学习,,讲解详细,,高清pdf。不辣眼睛

    NHibernate Inverse & Cascade

    NHibernate Inverse & Cascade

    Nhibernate_一步一步

    Nhibernate_一步一步

    NHibernate中文帮助手册API

    NHibernate 参考文档手册 chm,NHIBERNATE-符合.Net习惯的关系数据库持久化,手册目录摘要:  前言  1. 第一个NHibernate应用程序  1.1. 开始NHibernate之旅  1.2. 第一个持久化类  1.3. 映射cat  1.4. ...

    NHibernate中文文档

    而NHibernate,顾名思义,如同NUnit,NAnt一样,是基于.Net的Hibernate实现,但是目前介绍NHibernate的资料非常少,缺少一个系统完整的教程来全面的展现和深入NHibernate,而且现在NHibernate的文档又残缺不全,少的...

    NHibernate 3 3 Sample 例子

    NHibernate 3.3 Sample

    nhibernate2.1.2帮助

    nhibernate2.1.2帮助手册nhibernate2.1.2帮助手册nhibernate2.1.2帮助手册nhibernate2.1.2帮助手册nhibernate2.1.2帮助手册nhibernate2.1.2帮助手册nhibernate2.1.2帮助手册

    学习NHibernate的范例

    学习NHibernate的范例!!

    NHibernate实例

    NHibernate小实例 增删改查NHibernate

    NHibernate Designer 2.0

    NHibernate Designer 2.0 发布了,该版本包含很多的改进以及用户体验的提升。 关键的新特性: 增加每个人生成单独文件的选项 创建新模型时的设置向导 支持内置 XML 或 Fluent NHibernate 生成映射 配置向导功能,更...

Global site tag (gtag.js) - Google Analytics