mirror of
https://github.com/corda/corda.git
synced 2025-04-27 06:19:54 +00:00
Merge pull request #6852 from corda/dan/ENT-6092-port-to-os
ENT-6092 Add flush to `MockServices.withEntityManager` (#4180)
This commit is contained in:
commit
ade302be73
@ -251,11 +251,15 @@ open class MockServices private constructor(
|
|||||||
override fun jdbcSession(): Connection = persistence.createSession()
|
override fun jdbcSession(): Connection = persistence.createSession()
|
||||||
|
|
||||||
override fun <T : Any?> withEntityManager(block: EntityManager.() -> T): T {
|
override fun <T : Any?> withEntityManager(block: EntityManager.() -> T): T {
|
||||||
return block(contextTransaction.entityManager)
|
return contextTransaction.entityManager.run {
|
||||||
|
block(this).also { flush () }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun withEntityManager(block: Consumer<EntityManager>) {
|
override fun withEntityManager(block: Consumer<EntityManager>) {
|
||||||
return block.accept(contextTransaction.entityManager)
|
return contextTransaction.entityManager.run {
|
||||||
|
block.accept(this).also { flush () }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user