- 浏览: 502653 次
- 性别:
- 来自: 沈阳
文章分类
- 全部博客 (437)
- Windows设置 (2)
- oracle数据库 (39)
- bug--jsp (4)
- j2se (13)
- js (40)
- bug-tomcat不能启动程序 (1)
- Hibernate (29)
- eclipse (20)
- java (65)
- 设计模式 (6)
- bug (18)
- PL/SQL (11)
- 前台 (5)
- 杂谈 (25)
- UML (1)
- jdbc编程 (2)
- 技术调研 (1)
- 数据通信 (2)
- ios (1)
- servlet自学笔记 (10)
- tomcat (9)
- SQL学习笔记 (6)
- java工具 (1)
- 数据库设计 (4)
- javascript (10)
- jsp (11)
- struts (17)
- ajax (7)
- linix/Unix (6)
- 资源 (3)
- spring (14)
- 算法 (5)
- 计算机网络 (2)
- http (5)
- c++ (2)
- web应用 (3)
- jvm (5)
- java中的字符编码 (14)
- java代码库 (2)
- classloader (1)
- 读书笔记 (1)
- c (1)
- 开源软件 (1)
- svn (1)
- AOP (1)
- java序列化 (1)
- 多线程 (4)
- The legendary programmers (1)
- Apache http Server (1)
- html tag (3)
- struts1.X学习笔记 (5)
- buffalo (1)
- 自己收藏 (0)
- TOEFL(IBT) (1)
- 网络翻墙 (0)
- 编译原理 (1)
- 书籍推荐 (1)
- css (10)
- javaee环境搭建资料 (1)
- 开源工具 (1)
- 美国生活 (1)
- spring自学 (3)
- log4j (3)
- 算法与数据结构 (5)
- 病毒,插件处理大全 (1)
- flex (2)
- webservice (1)
- git (7)
- cs (1)
- html (4)
- javaee (6)
- 开车 (0)
- springmvc (3)
- 互联网架构 (2)
- intellij idea (18)
- maven (15)
- mongodb (2)
- nginx (1)
- react (3)
- java基础例子 (2)
- springboot (2)
- 培训 (5)
- mysql (3)
- 数据库 (3)
- 生活 (2)
- intellij (3)
- linux (2)
- os (3)
最新评论
-
潇洒天涯:
[color=blue][color=cyan] ...
oracle 通过 nvl( )函数sql 查询时为 空值 赋默认值 -
hekai1990:
受教了..
oracle中的varchar2
这个错误我一共遇到过两次,一直没有找到很好的解决方案,这个错误产生 其实要解决这个问题很简单,只需要进行session.clean()操作就可以解决 后来我还发现这种错误经常出现在一对多映射和多对多映射,请大家在 Hibernate 疑难异常及处理 1、a different object with the same identifier value was already associated with the session。 错误原因:在hibernate中同一个session里面有了两个相同标识但是是不同实体。 解决方法一:session.clean() PS:如果在clean操作后面又进行了saveOrUpdate(object)等改变数据状态的操作,有可能会报出"Found two representations of same collection"异常。 解决方法二:session.refresh(object) PS:当object不是数据库中已有数据的对象的时候,不能使用session.refresh(object)因为该方法是从hibernate的session中去重新取object,如果session中没有这个对象,则会报错所以当你使用saveOrUpdate(object)之前还需要判断一下。 解决方法三:session.merge(object) PS:Hibernate里面自带的方法,推荐使用。 2、Found two representations of same collection 错误原因:见1。 解决方法:session.merge(object) 以上两中异常经常出现在一对多映射和多对多映射中
原因相信大家都知道,因为在hibernate中同一个session里面有了两个相同标识
但是是不同实体,当这时运行saveOrUpdate(object)操作的时候就会报这个错误。
呵呵,也许你会说,你这么说跟没说没什么区别,我承认,呵呵,我不知道具体
为什么会产生这个错误,要不然也不会很久都没有解决,现在,给出一个临时的
解决方案,给向我一样,没有办法找到根源的人一个能够继续执行下去的方法
(当然是对的,只是不是从产生原因入手)
了,但是你在clean操作后面又进行了saveOrUpdate(object)操作,有可能
会报出"Found two representations of same collection",我找了很多资料,
没有什么很好的解释,其中这篇文章帮助最大
http://opensource.atlassian.com/projects/hibernate/browse/HHH-509。
最后通过session.refresh(object)方法就可以解决了,注意,当object不
是数据库中已有数据的对象的时候,不能使用session.refresh(object)因
为refresh是从hibernate的session中去重新取object,如果session中没
有这个对象,则会报错所以当你使用saveOrUpdate(object)之前还需要判
断一下
当然这个问题最容易解决的办法还是使用Hibernate里面自带的merge()
方法。不过我始终觉得碰到问题就用这种软件自带的非常用方法
(和saveOrUpdate(),save(),update()相比)感觉十分不爽。
使用一对多和多对多映射的时候要小心一些
发表评论
-
Hibernate:Envers 审计
2018-09-17 23:57 531https://blog.csdn.net/Silen ... -
【转】Spring3.3 整合 Hibernate3、MyBatis3.2 配置多数据源/动态切换数据源 方法
2016-12-13 15:07 703http://www.cnblogs.com/hoojo ... -
【转】Spring3 整合Hibernate3.5 动态切换SessionFactory (切换数据库方言)
2016-12-13 15:05 768http://www.cnblogs.com/hoojo ... -
Hibernate中的三种对象状态:
2015-11-15 18:33 416Hibernate中的三种对象状态: 1.瞬时(tr ... -
【转】Hibernate过滤器使用窍门
2015-09-08 17:13 553Hibernate过滤器(filter)是全局有效的 ... -
【转】Hibernate left join(左连接)
2015-08-26 17:27 1995如果是内连接的多表查询可以不用join关键字,在where ... -
【转】Hibernate 所有缓存机制详解
2015-08-26 14:50 655hibernate提供的一级缓存 hibernate是一个 ... -
【转】Hibernate中session的clear(),flush(),evict()方法详解
2015-08-26 14:22 10461.Clear 方法 无论是Load 还是 Get ... -
object references an unsaved transient instance - save the transient instance be
2015-04-15 10:17 912在做hibernate保存时出现异常object refer ... -
【转】An association from the table * refers to an unmapped class: *
2015-04-08 10:13 962解决方法:class路径没写正确。有三个地方需要注意1、< ... -
hibernate映射文件one-to-one 元素属性(转)
2013-01-07 19:13 835one-to-one 元素 属性: name:映射类 ... -
【转】Hibernate中重要对象的详解
2012-12-13 14:18 674★→→SessionFactory (org.hibernat ... -
【转】很详细的spirng+struts+hibernate实例
2012-12-13 14:17 2379本文并不想介绍Struts,Spring,Hiber ... -
【转】Hibernate中id标签
2012-11-19 14:32 846核心提示:Hibernate中,id标签下的可选gener ... -
【转】hibernate动态创建表,修改表字段
2012-10-22 18:50 1053我们知道,hibernate的tool工具中有个包hbm2dd ... -
【转】hibernate many-to-one(多对一)及 cascade(级联)
2012-09-19 16:18 804Model public class User { // ... -
报错:使用hibernate字符串超长
2012-09-13 17:47 1578在使用varchar2类型时必须指定其长度(最小1字节 ... -
包名不同的同名类的hibernate冲突
2012-09-13 14:38 1217在实际开发中,在有类a.b.c.POClass和a.b.c ... -
【转】hibernate自定义类型部分接口详解--用户自定义类型
2012-08-31 16:48 0UserType public interface Us ... -
ORA-00904: "THIS_"."C_UNIT": 标识符无效
2012-08-02 13:40 1577hibernate could not resolve pro ...
相关推荐
a different object with the same identifier value was already associated with the session 是一种常见的异常,通常是由于在 Hibernate 中同一个 session 里面有了两个相同标识但是是不同实体所致。解决方案有...
5. `a different object with the same identifier value was already associated with the session` 这个异常表明在同一个Hibernate Session中存在两个具有相同标识但实际是不同对象的情况。处理方法有: - 使用`...
数字对象标识符(Digital Object Identifier,简称DOI)是一种持久性标识符,用于唯一地标识数字资源,如学术文章、数据集等。DOI系统由国际DOI基金会管理,并在出版界广泛采用。随着数字资源的增加以及对资源描述的...
In these systems, packets are transmitted over the same wireless infrastructure used for cellular telephony, with the base station thus being managed by a telecommunications provider. This provides ...
When the SID is found in a value it is replaced with the new computer SID, and when the SID is found in a name, the key and its subkeys are copied to a new subkey that has the same name except with ...
- When the signal conditioning function "S&M" was used for a byte value, the driver wrote wrong values to the PLC. Build 223 : New Functions: - The number of supported NetLinks has been ...
- FIX: The value of some string flex-properties that began with a parenthese or curly bracket had no apostrophe at the end; that caused an error when reading. (fixed TPropList.SavePropValue for the ...
Another type of table lock is a schema stability lock (Sch-S) and is compatible with all table locks except the schema modification lock (Sch-M). The schema modification lock (Sch-M) is incompatible ...
Each index row in node pages contains an index key (or set of keys for a composite index) and a pointer to a page at the next level for which the first key value is the same as the key value in the ...
Adds a response header with the given name and value. addIntHeader(String, int) - Method in class javax.servlet.http.HttpServletResponseWrapper The default behavior of this method is to call ...
two and must be the same length on both ends.Term ID: A unique identifier for a Term within a Stream. Starts randomly. Must increase monotonically. Can wrap around. Can not go back to a wrapped ...
This was due to a problem where it would be freed automatically if there was a problem with the ArchiveStream when trying to open it as a zip file (possibly corrupt). Best practice is that ...
EXIF Data and the Map Object The speed Property Conclusion Chapter 11 : Microphone and Audio The Microphone Audio Assets Working with Sounds ID3 Tags Modifying Sound Raw Data and the Sound Spectrum ...
The "Identifier Case Sensitive" check box, which enables case-sensitive processing of database object identifier names, is added to MySQL Server Options The documentation generation for Enum members ...
本文介绍Oralce数据库中,表名可以使用的最大长度。这个长度也是Oracle...*Cause: An identifier with more than 30 characters was specified. *Action: Specify at most 30 characters. 从这个错误提示可以看出
This CD contains both the source code for every program discussed in the book as well as executable files. You can open the source files in the Microsoft Visual C++ environment or in your favorite ...
make use of the CAN implementations that are already available on the market, or of new controllers that implement both formats. In order to distinguish standard and extended format the first reserved...
### 解决Error C2065:'_beginthreadex':Undeclared Identifier #### 错误概述 在编译过程中遇到“Error C2065:'_beginthreadex':undeclared identifier”这一错误信息时,通常意味着编译器无法识别`_...
Stores a unique identifier for the file, allowing for the identification of files across different volumes. ##### Attribute - $SECURITY_DESCRIPTOR (0x50) Holds security-related information, such as ...