mirror of
https://github.com/corda/corda.git
synced 2025-04-11 13:21:26 +00:00
ENT-2124 Flush before detach in Hibernate (#3462)
This commit is contained in:
parent
34923506f4
commit
322a8d4f54
@ -123,8 +123,12 @@ abstract class AppendOnlyPersistentMapBase<K, V, E, out EK>(
|
||||
}
|
||||
|
||||
protected fun loadValue(key: K): V? {
|
||||
val result = currentDBSession().find(persistentEntityClass, toPersistentEntityKey(key))
|
||||
return result?.apply { currentDBSession().detach(result) }?.let(fromPersistentEntity)?.second
|
||||
val session = currentDBSession()
|
||||
// IMPORTANT: The flush is needed because detach() makes the queue of unflushed entries invalid w.r.t. Hibernate internal state if the found entity is unflushed.
|
||||
// We want the detach() so that we rely on our cache memory management and don't retain strong references in the Hibernate session.
|
||||
session.flush()
|
||||
val result = session.find(persistentEntityClass, toPersistentEntityKey(key))
|
||||
return result?.apply { session.detach(result) }?.let(fromPersistentEntity)?.second
|
||||
}
|
||||
|
||||
operator fun contains(key: K) = get(key) != null
|
||||
|
Loading…
x
Reference in New Issue
Block a user