diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockServices.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockServices.kt index 899d36cdc3..efd5813736 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockServices.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/MockServices.kt @@ -251,11 +251,15 @@ open class MockServices private constructor( override fun jdbcSession(): Connection = persistence.createSession() override fun withEntityManager(block: EntityManager.() -> T): T { - return block(contextTransaction.entityManager) + return contextTransaction.entityManager.run { + block(this).also { flush () } + } } override fun withEntityManager(block: Consumer) { - return block.accept(contextTransaction.entityManager) + return contextTransaction.entityManager.run { + block.accept(this).also { flush () } + } } } }