我理解的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在什麼時候用上了悲觀鎖. 還望指點一二。
相關文章
- 深入理解Aspnet Core之Identity(4)IDE
- Object.keys()的簡單理解Object
- 簡單的理解 Object.defineProperty()Object
- org.hibernate.TransientObjectException: object references an unsaved transient instance - save the tObjectException
- Javascrip—理解Object.defineProperty的作用(15)JavaObject
- 淺解理解 Object.defineProperty()Object
- 深入理解Object.createObject
- Kubernetes的Local Persistent Volumes使用小記
- 'This NSPersistentStoreCoordinator has no persistent stores 報錯
- Object物件你真理解了嗎?Object物件
- 理解Java中物件基礎Object類Java物件Object
- 我所理解的Arthas
- 我所理解的 CocoaPods
- 我對抽象的理解抽象
- 我所理解的前端前端
- 5分鐘徹底理解Object.keysObject
- SCOPE_IDENTITY、IDENT_CURRENT 和 @@IDENTITY(zt)IDE
- 我理解的ES6
- 我理解的 Java 泛型Java泛型
- 我對JavaScript物件的理解JavaScript物件
- 我所理解的微服務微服務
- Kubernetes 跨 StorageClass 遷移 Persistent Volumes 完全指南
- 重置identity值IDE
- Hibernate的基礎
- Hibernate SQL方言 (hibernate.dialect)SQL
- 我理解的前端視覺化前端視覺化
- Android:聊聊我所理解的MVPAndroidMVP
- 我所理解的介面設計
- 我理解的Clean程式碼 - macerubMac
- 說說我對 WSGI 的理解
- 我理解的分散式系統分散式
- 我理解的正規表示式
- 我理解的前端發展方向前端
- 我所理解的雲原生(二)
- 我是這樣理解EventLoop的OOP
- 我對註冊中心的理解
- Vue 3學習理解 Object.assign淺複製VueObject
- Debian使用iptables-persistent持久化iptables規則持久化
- Hibernate