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:
Rick Parker 2021-01-29 17:06:12 +00:00 committed by GitHub
commit ade302be73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -251,11 +251,15 @@ open class MockServices private constructor(
override fun jdbcSession(): Connection = persistence.createSession()
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>) {
return block.accept(contextTransaction.entityManager)
return contextTransaction.entityManager.run {
block.accept(this).also { flush () }
}
}
}
}