Terry's blog

Focus on bigdata and cloud.

博客园 首页 新随笔 联系 订阅 管理
  383 随笔 :: 1 文章 :: 268 评论 :: 83万 阅读

随笔分类 -  NHibernate

摘要:概述: 在有些情况下,我只想更新记录中的一个字段的值.比如:浏览完这条记录后,我把其中的是否浏览置为1.Nhibernate中提供了Native SQL,其中有一个方法ExecuteUpdate()来实现这个功能.代码如下: [代码] 阅读全文
posted @ 2009-04-14 10:49 王晓成 阅读(2525) 评论(8) 推荐(0) 编辑

摘要:概述: 当用Nhibernate操作主从表时,往主表插入数据时,当执行到提交事务时出现如下错误: 此 OracleParameterCollection 的 Count=4 的索引 4 无效。 在 System.Data.OracleClient.OracleParameterCollection.RangeCheck(Int32 index) 在 System.Data.OracleC... 阅读全文
posted @ 2009-04-01 17:32 王晓成 阅读(1629) 评论(2) 推荐(0) 编辑

摘要:概述: 在项目中应用NHibernate架构时,会经常遇到多表查询.因为项目上要用到,通过多天的查询总结了以下两种解决方案. 解决方案: (1)使用HQL语句,然后把查询出的结果存入临时表中,然后再进行绑定. (2)使用select new OaxtJoinGlxt这种语法,根据查询的内容自己构建相应的实体类. 第一种方案实现具体过程: 我的需求如下: 我需要查询JkptOa... 阅读全文
posted @ 2009-03-05 10:01 王晓成 阅读(5127) 评论(10) 推荐(0) 编辑

摘要: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... 阅读全文
posted @ 2009-03-03 17:38 王晓成 阅读(784) 评论(0) 推荐(0) 编辑

摘要:概述: 在Nhibernate对数据记录进行更新的时候,如果对同一条记录进行重复执行修改时,出现如下错误: a different object with the same identifier value was already associated with the session: 25, of entity: Model.JkptOaxtWeatherforecast. 解决办法... 阅读全文
posted @ 2009-02-26 10:33 王晓成 阅读(1296) 评论(1) 推荐(0) 编辑

摘要:概述: 当使用Nhibernate查询表中的数据时,如果表中存在复合主键,如果没有在相应的实体类中重写Equals(),那么将会出现"Could not compile the mapping document: TestCleanSnow.JkptGlxtUser.hbm.xml".当跟踪出错的内部信息的时候会发现,内部异常为"composite-id class must overrid... 阅读全文
posted @ 2009-02-24 16:46 王晓成 阅读(2518) 评论(4) 推荐(0) 编辑

摘要:概述: 当运行 session.Save(tnp);时,出现这个"Unknown entity class: TestCleanSnow.TestNhibernatePerson"这个异常. 映射文件 TestNhibernatePerson.hbm.xml如下: Code highlighting produced by Actipro CodeHighlighter ... 阅读全文
posted @ 2009-02-17 16:06 王晓成 阅读(3501) 评论(1) 推荐(0) 编辑

摘要:我用的是Oracle9i,应用程序app.config的配置如下" Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> NHibernate.Dialect.MsSql2000D... 阅读全文
posted @ 2009-02-16 15:46 王晓成 阅读(2353) 评论(0) 推荐(1) 编辑

摘要:主键产生器 可选项说明: 1) assigned 主键由外部程序负责生成,无需NHibernate参与。 2) hilo 通过hi/lo 算法实现的主键生成机制,需要额外的数据库表保存主 键生成历史状态。 3) seqhilo 与hilo 类似,通过hi/lo 算法实现的主键生成机制,只是主键历史 状态保存在Sequence中,适用于支持Sequence的数据库,如Oracle。 4) incr... 阅读全文
posted @ 2009-02-13 16:03 王晓成 阅读(1387) 评论(1) 推荐(1) 编辑

摘要:代码如下: Configuration config = new Configuration(); config.AddAssembly("TestCleanSnow"); ISessionFactory factory = config.BuildSessio... 阅读全文
posted @ 2009-02-13 11:07 王晓成 阅读(353) 评论(1) 推荐(0) 编辑

摘要:在执行 session.Save(cs); 时,出现could not get next sequence value[SQL: SQL not available] Nhibernate 解决办法: 把相应XML的 改为 以上我做Oracle时出现的错误,操作sqlserver的时候应该为 . 阅读全文
posted @ 2009-02-12 15:07 王晓成 阅读(1509) 评论(0) 推荐(0) 编辑

摘要:在加载映射文件及相应的类文件的引用时 Configuration config = new Configuration(); config.AddAssembly("TestCleanSnow"); 出现如下异常: Could not compile the mapping document: TestCleanSnow.BjkptOaxtCleanupsnow... 阅读全文
posted @ 2009-02-12 14:50 王晓成 阅读(4613) 评论(2) 推荐(0) 编辑

摘要:在 ISessionFactory factory = config.BuildSessionFactory();时发生 NHibernate.InvalidProxyTypeException: The following types may not be used as proxies: TestCleanSnow.BjkptOaxtCleanupsnow: method set_IsDele... 阅读全文
posted @ 2009-02-12 14:43 王晓成 阅读(595) 评论(0) 推荐(0) 编辑

摘要:转载于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... 阅读全文
posted @ 2009-01-15 17:05 王晓成 阅读(313) 评论(0) 推荐(0) 编辑

摘要:如标题,我解决的方法用了下面的第三种方法. 下面的文章转载于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... 阅读全文
posted @ 2009-01-15 16:40 王晓成 阅读(1401) 评论(0) 推荐(0) 编辑

摘要:我出现此问题是因为app.config的配置有错,我用的是NHibernate2.0,把app.config配置成如下: Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> ... 阅读全文
posted @ 2009-01-15 16:35 王晓成 阅读(459) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示