我理解的Persistent Object Identity in Hibernate
>Persistent Object Identity
>The application may concurrently access the same persistent >state in two different sessions. However, an instance of a >persistent class is never shared between two Session instances. >Hence there are two different notions of identity:
>Persistent Identity foo.getId().equals( bar.getId() )
>JVM Identity foo==bar
>Then for objects returned by a particular Session, the two >notions are equivalent. However, while the application might >concurrently access the "same" (persistent identity) business >object in two different sessions, the two instances will >actually be "different" (JVM identity).
>This approach leaves Hibernate and the database to worry about >concurrency (the application never needs to synchronize on any >business object, as long as it sticks to a single thread per >Session) or object identity (within a session the application >may safely use == to compare objects).
不知我這樣理解對不對?
當不同的Session併發訪問同一個PO時,在JVM中,不同的Session拿到不同的ID(是不是做了PO不同的副本?或者是timestamp什麼的?),這樣就可以避免PO同步問題,留給Hibernate 和資料庫處理。我認為Hibernate會使用樂觀鎖,在提交的時候檢查一下是否有變化,而對於資料庫,它也會用相應的各種鎖和事務來控制。
另外,不知道Hibernate在什麼時候用上了悲觀鎖. 還望指點一二。
>The application may concurrently access the same persistent >state in two different sessions. However, an instance of a >persistent class is never shared between two Session instances. >Hence there are two different notions of identity:
>Persistent Identity foo.getId().equals( bar.getId() )
>JVM Identity foo==bar
>Then for objects returned by a particular Session, the two >notions are equivalent. However, while the application might >concurrently access the "same" (persistent identity) business >object in two different sessions, the two instances will >actually be "different" (JVM identity).
>This approach leaves Hibernate and the database to worry about >concurrency (the application never needs to synchronize on any >business object, as long as it sticks to a single thread per >Session) or object identity (within a session the application >may safely use == to compare objects).
不知我這樣理解對不對?
當不同的Session併發訪問同一個PO時,在JVM中,不同的Session拿到不同的ID(是不是做了PO不同的副本?或者是timestamp什麼的?),這樣就可以避免PO同步問題,留給Hibernate 和資料庫處理。我認為Hibernate會使用樂觀鎖,在提交的時候檢查一下是否有變化,而對於資料庫,它也會用相應的各種鎖和事務來控制。
另外,不知道Hibernate在什麼時候用上了悲觀鎖. 還望指點一二。
相關文章
- C++永久物件儲存 (Persistent Object Storage for C++) (轉)C++物件Object
- TN002: Persistent Object Data Format(永久物件的資料格式) (轉)ObjectORM物件
- Hibernate 框架理解框架
- Hibernate flush理解
- 理解Object.defineProperty的作用Object
- 理解Object.defineProperty()Object
- 簡單的理解 Object.defineProperty()Object
- Hibernate in Action: Practical Object/Relational MappingObjectAPP
- Guru of the Week 條款11:物件等同(Object Identity)問題 (轉)物件ObjectIDE
- 這些屬性的含義,我的理解對嗎?(jdbc2.0或hibernate)JDBC
- Object.keys()的簡單理解Object
- Javascrip—理解Object.defineProperty的作用(15)JavaObject
- 深入理解Aspnet Core之Identity(4)IDE
- 有個關於ddd value object 和 hibernate的問題Object
- sourcemaps and persistent modification in chromeChrome
- hibernate裡inverse和cascade的理解
- 淺解理解 Object.defineProperty()Object
- 深入理解Object.createObject
- DDD 我的理解
- Java Web之理解 Hibernate And MyBatisJavaWebMyBatis
- 正確理解Hibernate Inverse (轉)
- 深入理解hibernate的三種狀態
- Hibernate中flush機制的詳細理解
- Object物件你真理解了嗎?Object物件
- 無狀態會話ejb object的個人理解會話Object
- @@IDENTITY與SCOPE_IDENTITY()IDE
- 我對抽象的理解抽象
- 我所理解的Arthas
- 我所理解的前端前端
- 我對引擎的理解
- 我對SNS的理解
- 命令模式(我的理解)模式
- 我所理解的機器學習機器學習
- org.hibernate.TransientObjectException: object references an unsaved transient instance - save the tObjectException
- 給我們的Empty Object加個圖示Object
- 理解Java中物件基礎Object類Java物件Object
- Hibernate分頁查詢原理解讀
- @@IDENTITY、SCOPE_IDENTITY()和IDENT_CURRENT()的辨析IDE