`
tiantao78
  • 浏览: 338 次
  • 性别: Icon_minigender_1
  • 来自: 北京
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

有关a different object with the same identifier value in a session

阅读更多
直接的意思就不说了,只用自己的经验说一下为什么会出现这个问题,
一般情况下,使用SPRING的面向切面的事务管理容易出现这个问题,原因是在进入一个新的事务前取出的PO对象因为之前的事务结束对应的session会被关闭,这时的PO对象已经为游离状态,在下一个事务方法内如果打开了与其关联的对象那此对象会自动被加载,这样新的session中就会有一个PO对象和一个游离对象,如果此时操作之前的游离对象,那么就会出现这个错误,只要保证游离对象在此session内成为PO对象,就不会出现以上问题。举例:
方法a(){
   Object c = ..从事务中取得后session关闭
   b(c);调用方法b
}

方法b(Object c){
   Object d = ...从新session中取得d对象但d 对象关联加载了c对象
  session.update(c) 此时就会出现如标题的错误
}
分享到:
评论

相关推荐

    hibernate常见异常

    a different object with the same identifier value was already associated with the session 是一种常见的异常,通常是由于在 Hibernate 中同一个 session 里面有了两个相同标识但是是不同实体所致。解决方案有...

    计算机网络第六版答案

    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 ...

    The Digital Object Identifier initiative: metadata implications

    数字对象标识符(Digital Object Identifier,简称DOI)是一种持久性标识符,用于唯一地标识数字资源,如学术文章、数据集等。DOI系统由国际DOI基金会管理,并在出版界广泛采用。随着数字资源的增加以及对资源描述的...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    - 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 ...

    servlet2.4doc

    Returns the object bound with the specified name in this session, or null if no object is bound under the name. getAttributeNames() - Method in interface javax.servlet.ServletContext Returns an ...

    hibernate常见问题及处理.doc

    5. `a different object with the same identifier value was already associated with the session` 这个异常表明在同一个Hibernate Session中存在两个具有相同标识但实际是不同对象的情况。处理方法有: - 使用`...

    S7A驱动720版本

    whether the driver is running in the demo mode or in the licenced mode (with a valid key). - New control tag: "!RuntimeMode:S7A". A digital (i.e. DI) or analog (i.e. AI) block with the I/O ...

    高性能消息传输机制Aeron.zip

    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 ...

    微软内部资料-SQL性能优化5

    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 ...

    微软内部资料-SQL性能优化3

    To make use of either more or less strict isolation levels in applications, locking can be customized for an entire session by setting the isolation level of the session with the SET TRANSACTION ...

    NewSID(光学习一下代码就可以了,没看清楚介绍别运行)

    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 ...

    windows程序设计

    the executable in the DEBUG directory has been compiled with the UNICODE identifier defined. In most cases, this means that the executable in the DEBUG directory will not run under Windows 95 or ...

    jwts-not-safe-e-book.pdf

    - Clients include the session ID in each subsequent request to the server, usually as a cookie value or in an HTTP header. This allows the server to identify the client and retrieve the associated ...

    developing android application with adobe air.part3.rar

    What Is in the AIR SDK New ActionScript Libraries AIR on the Desktop Versus AIR on Android Mobile Flash Player 10.1 Versus AIR 2.6 on Android Chapter 2 : Call Me, Text Me Setting Up Your Device ...

    查看进程工具tlist.exe

    ProcessName is the name of the process (with or without file name extension), not a pattern. If the value of ProcessName does not match any running process, TList displays -1. If it matches more ...

    VclZip pro v3.10.1

    Using '*.*' as a wildcard in files added to FilesList now is the same as using '*'. VCLZip will now check for CancelTheOperation during initial building of the fileslist instead of just during ...

    Devart LinqConnect 3.1

    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 ...

    Network Security: Private Communication in a Public World, Second Edition

    Network Security: Private Communication in a Public World, Second Edition By Charlie Kaufman, Radia Perlman, Mike Speciner ............................................... Publisher: Prentice Hall ...

    DEV控件客户端代码

    ///Serves as the base object for all the editors included in the client-side object model. /// /// ///Gets the unique, hierarchically-qualified identifier for the control. Value: The fully-...

Global site tag (gtag.js) - Google Analytics