Skip to content

Commit

Permalink
Merge pull request corda#6852 from corda/dan/ENT-6092-port-to-os
Browse files Browse the repository at this point in the history
ENT-6092 Add flush to `MockServices.withEntityManager` (corda#4180)
  • Loading branch information
rick-r3 authored Jan 29, 2021
2 parents d214f5e + 682de39 commit ade302b
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 () }
}
}
}
}
Expand Down

0 comments on commit ade302b

Please sign in to comment.