摘要:概述: 在有些情况下,我只想更新记录中的一个字段的值.比如:浏览完这条记录后,我把其中的是否浏览置为1.Nhibernate中提供了Native SQL,其中有一个方法ExecuteUpdate()来实现这个功能.代码如下: [代码]
阅读全文
随笔分类 - NHibernate
摘要:概述: 当用Nhibernate操作主从表时,往主表插入数据时,当执行到提交事务时出现如下错误: 此 OracleParameterCollection 的 Count=4 的索引 4 无效。 在 System.Data.OracleClient.OracleParameterCollection.RangeCheck(Int32 index) 在 System.Data.OracleC...
阅读全文
摘要:概述: 在项目中应用NHibernate架构时,会经常遇到多表查询.因为项目上要用到,通过多天的查询总结了以下两种解决方案. 解决方案: (1)使用HQL语句,然后把查询出的结果存入临时表中,然后再进行绑定. (2)使用select new OaxtJoinGlxt这种语法,根据查询的内容自己构建相应的实体类. 第一种方案实现具体过程: 我的需求如下: 我需要查询JkptOa...
阅读全文
摘要:Named SQL queries may be defined in the mapping document and called in exactly the same way as a named HQL query. In this case, we do not need to call AddEntity(). Code highlighting produced by Act...
阅读全文
摘要:概述: 在Nhibernate对数据记录进行更新的时候,如果对同一条记录进行重复执行修改时,出现如下错误: a different object with the same identifier value was already associated with the session: 25, of entity: Model.JkptOaxtWeatherforecast. 解决办法...
阅读全文
摘要:概述: 当使用Nhibernate查询表中的数据时,如果表中存在复合主键,如果没有在相应的实体类中重写Equals(),那么将会出现"Could not compile the mapping document: TestCleanSnow.JkptGlxtUser.hbm.xml".当跟踪出错的内部信息的时候会发现,内部异常为"composite-id class must overrid...
阅读全文
摘要:概述: 当运行 session.Save(tnp);时,出现这个"Unknown entity class: TestCleanSnow.TestNhibernatePerson"这个异常. 映射文件 TestNhibernatePerson.hbm.xml如下: Code highlighting produced by Actipro CodeHighlighter ...
阅读全文
摘要:我用的是Oracle9i,应用程序app.config的配置如下" Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> NHibernate.Dialect.MsSql2000D...
阅读全文
摘要:主键产生器 可选项说明: 1) assigned 主键由外部程序负责生成,无需NHibernate参与。 2) hilo 通过hi/lo 算法实现的主键生成机制,需要额外的数据库表保存主 键生成历史状态。 3) seqhilo 与hilo 类似,通过hi/lo 算法实现的主键生成机制,只是主键历史 状态保存在Sequence中,适用于支持Sequence的数据库,如Oracle。 4) incr...
阅读全文
摘要:代码如下: Configuration config = new Configuration(); config.AddAssembly("TestCleanSnow"); ISessionFactory factory = config.BuildSessio...
阅读全文
摘要:在执行 session.Save(cs); 时,出现could not get next sequence value[SQL: SQL not available] Nhibernate 解决办法: 把相应XML的 改为 以上我做Oracle时出现的错误,操作sqlserver的时候应该为 .
阅读全文
摘要:在加载映射文件及相应的类文件的引用时 Configuration config = new Configuration(); config.AddAssembly("TestCleanSnow"); 出现如下异常: Could not compile the mapping document: TestCleanSnow.BjkptOaxtCleanupsnow...
阅读全文
摘要:在 ISessionFactory factory = config.BuildSessionFactory();时发生 NHibernate.InvalidProxyTypeException: The following types may not be used as proxies: TestCleanSnow.BjkptOaxtCleanupsnow: method set_IsDele...
阅读全文
摘要:转载于http://abluedog.cnblogs.com/archive/2006/04/15/375862.html 基本的软件环境如下: 1.NHibernate http://www.nhibernate.org/ 2.Code Smith http://www.codesmithtools.com/ 3.NHibernate模板 点击这里下载 当然,少不了VS2005跟SQLServ...
阅读全文
摘要:如标题,我解决的方法用了下面的第三种方法. 下面的文章转载于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-mappi...
阅读全文
摘要:我出现此问题是因为app.config的配置有错,我用的是NHibernate2.0,把app.config配置成如下: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> ...
阅读全文