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. 
     
                待续 
     
    待续。。
  • 相关阅读:
    道路和航线
    Sorting It All Out
    Sightseeing Cows(0/1分数规划+Spfa判负环)
    【模板】缩点
    间谍网络
    Tarjan算法专练
    数论知识点总结
    博客迁移到博客园
    第一届CCPC河南省赛
    find程序实现
  • 原文地址:https://www.cnblogs.com/wangguowen27/p/NHibernate.html
Copyright © 2011-2022 走看看