zoukankan      html  css  js  c++  java
  • 项目中NHibernate问题及解决方法

     1.用户代码未处理 NHibernate.QueryException
      Message=Type mismatch in NHibernate.Criterion.SimpleExpression: PPPPortfolioGUID expected type System.String, actual type DecoratorAopProxy_58a5990eecd14c80ac61500fb1f1321f
      Source=NHibernate
    QueryException  在查询的时候出错,但是查询条件检查没错,从字面上是类型不一致
      原来:<many-to-one column="PPP_PortfolioGUID" name="PPPPortfolioGUID" /> 
     修改:
     <many-to-one column="PPP_PortfolioGUID" name="PPPPortfolioGUID" class="IDST.Entity.Tables.PTPortfolioArchivedEntity,IDST.Entity" />
     
      nhibernate 使用hql语言进行查询操作,其执行的查询是对象的相关信息,而在nhibernate中,对象的属性是由.hb.xml来定义,故其查询的属性需与hb.xml文件定义字段相一致,包括大小写,如,Isession.CreateQuery(“select c.cusID  from customer c"),其cusID需与hb.xml中定义的一致
     
    2.
    "Could not find the dialect in the configuration"异常
    异常描述:

    NHibernate.MappingException: Could not compile the mapping document: Model.FriendLink.hbm.xml ---> System.InvalidOperationException: Could not find the dialect in the configuration
      在 NHibernate.Dialect.Dialect.GetDialect(IDictionary`2 props)
      在 NHibernate.Cfg.Configuration.AddValidatedDocument(NamedXmlDocument doc)
    解决方法: 

    配置文件中xmlns="urn:nhibernate-configuration-2.2"千万不能忘记,确保没有忘掉xmlns="urn:nhibernate-configuration-2.2"就可以解决这个bug. 
     
                待续 
     
    待续。。
  • 相关阅读:
    《Effective java》读书笔记
    Ansible playbook
    Ansible模块
    Ansible介绍与安装
    HDFS完全分布式集群搭建
    screen配置窗口显示
    K8s下部署Istio
    使用RKE快速部署k8s集群
    Oracle批量创建同义词
    k8s基本概念
  • 原文地址:https://www.cnblogs.com/wangguowen27/p/NHibernate.html
Copyright © 2011-2022 走看看