mirror of
https://github.com/corda/corda.git
synced 2025-06-13 20:58:19 +00:00
[CORDA-3303] - Avoid flushing when inside a cascade (#5575)
* [CORDA-3303] - Avoid flushing when inside a cascade * Remove listener infrastructure
This commit is contained in:
committed by
Rick Parker
parent
48fd78d059
commit
7666ca0d80
@ -25,9 +25,6 @@ class DatabaseTransaction(
|
||||
) {
|
||||
val id: UUID = UUID.randomUUID()
|
||||
|
||||
val flushing: Boolean get() = _flushingCount > 0
|
||||
private var _flushingCount = 0
|
||||
|
||||
val connection: Connection by lazy(LazyThreadSafetyMode.NONE) {
|
||||
database.dataSource.connection.apply {
|
||||
autoCommit = false
|
||||
@ -37,27 +34,6 @@ class DatabaseTransaction(
|
||||
|
||||
private val sessionDelegate = lazy {
|
||||
val session = database.entityManagerFactory.withOptions().connection(connection).openSession()
|
||||
session.addEventListeners(object : BaseSessionEventListener() {
|
||||
override fun flushStart() {
|
||||
_flushingCount++
|
||||
super.flushStart()
|
||||
}
|
||||
|
||||
override fun flushEnd(numberOfEntities: Int, numberOfCollections: Int) {
|
||||
super.flushEnd(numberOfEntities, numberOfCollections)
|
||||
_flushingCount--
|
||||
}
|
||||
|
||||
override fun partialFlushStart() {
|
||||
_flushingCount++
|
||||
super.partialFlushStart()
|
||||
}
|
||||
|
||||
override fun partialFlushEnd(numberOfEntities: Int, numberOfCollections: Int) {
|
||||
super.partialFlushEnd(numberOfEntities, numberOfCollections)
|
||||
_flushingCount--
|
||||
}
|
||||
})
|
||||
hibernateTransaction = session.beginTransaction()
|
||||
session
|
||||
}
|
||||
|
Reference in New Issue
Block a user