Merge fixes

This commit is contained in:
Shams Asari
2018-07-24 17:47:20 +01:00
parent 02fae5f385
commit d040945b0e
9 changed files with 47 additions and 45 deletions

View File

@ -63,7 +63,6 @@ val contextDatabaseOrNull: CordaPersistence? get() = _contextDatabase.get()
class CordaPersistence(
databaseConfig: DatabaseConfig,
schemas: Set<MappedSchema>,
val jdbcUrl: String,
attributeConverters: Collection<AttributeConverter<*, *>> = emptySet()
) : Closeable {
companion object {
@ -72,11 +71,11 @@ class CordaPersistence(
private val defaultIsolationLevel = databaseConfig.transactionIsolationLevel
val hibernateConfig: HibernateConfiguration by lazy {
transaction {
HibernateConfiguration(schemas, databaseConfig, attributeConverters, jdbcUrl)
}
}
val entityManagerFactory get() = hibernateConfig.sessionFactoryForRegisteredSchemas
data class Boundary(val txId: UUID, val success: Boolean)
@ -84,8 +83,11 @@ class CordaPersistence(
private var _dataSource: DataSource? = null
val dataSource: DataSource get() = checkNotNull(_dataSource) { "CordaPersistence not started" }
fun start(dataSource: DataSource) {
private lateinit var jdbcUrl: String
fun start(dataSource: DataSource, jdbcUrl: String) {
_dataSource = dataSource
this.jdbcUrl = jdbcUrl
// Found a unit test that was forgetting to close the database transactions. When you close() on the top level
// database transaction it will reset the threadLocalTx back to null, so if it isn't then there is still a
// database transaction open. The [transaction] helper above handles this in a finally clause for you