360DOG.CN

<< 第一个 Hibernate 程式 | 首 页 | hibernate开发中遇到的问题,以及解决方法小记 2007-12-04 版权声明 :转载时请以超链接形式标明文章原始出处和作者信息及 本声明 http://360dog.blogbus.com/logs/11482017.html 1 .错误: object references an unsaved transient instance - save the transient instance before flushing: com.hkxy.bean.java.Sysblog; nested exception is org.hibernate.TransientObjectException : object references an unsaved transient instance - save the transient instance before flushing: com.hkxy.bean.java.Sysblog 解决方法: 没有可预期的实例,当然就要实例化对象咯 33. 出现异常: Exceptionobject references an unsaved transient instance - save the transient instance before flushing: src.persistent.Product 原因没有为某对象进行 set 设置, 如上边的这个就是某对象没有调用 setProduct 错误: org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException : No row with the given identifier exists: (不存在标识列)《暂时未解决,重启服务器,突然好了》 错误: Illegal attempt to associate a collection with two open sessions ( hibernate 的 session 提供了一级缓存,每个 session ,对同一个 id 进行两次 load ,不会发送两条 sql 给数据库,但是 session 关闭的时候,一级缓存就失效了。 ) sysblogarticle .setAmount( new Long( sysblogcommentService .selcom( sysblogarticle .getArticleid().toString()).size())); // 通过文章 id 获取文章评论数 sysblogarticle.setSysblogcomments( null );// 关键 sysblogarticleService .saveOrUpdate( sysblogarticle ); // 将文章中评论条数修改 参考: http://javaflasher.javaeye.com/blog/forum/17913 问题: Hbm 映射文件都生成好后,改数据库增加了默认值(如:将某个字段值设为 1 ),结果在插入的时候,数据库那边没有反应。 解决: dynamic-insert="true" dynamic-update="true" > ....... ........ sql-type="number(1) default 0" /> 在 sql-type 里面定义数据库默认值,那么 SchemeExport 的时候, DDL 就会加上 default 。然后 hbm 定义为 dynamic-insert="true" 和 dynamic-update="true" 错误: Unhandled Exception thrown: class ava.lang.NumberFormatException For input string: "4294967295" 原因: CLOB 对象没有转换格式输出 将其转换后,结果正常 随机文章: 巴基斯坦瓜达尔港赚钱了,中国人走了:巴要中国再修路 2008-03-28 中国外交部:西方“兜里没钱不是抢银行的理由”! 2008-03-28 第一个 Hibernate 程式 2007-12-04 Web2.0中流行的设计元素颜色 2007-12-04 Google网页搜索 VS Google桌面搜索 2007-12-04 收藏到: Del.icio.us Tag: hibernate 引用地址: meteor_liu225 发表于 13:34:50 | 日志分类: JAVA开发中遇到的问题 | 编辑 | 继续话题 | 转发 | 推荐 发表评论

原始快照:web.archive.org