From cec2f25c67c6ea4c5d44d9c005e71e28b8fee7ad Mon Sep 17 00:00:00 2001 From: szymonsztuka Date: Thu, 26 Apr 2018 19:05:55 +0100 Subject: [PATCH] ENT-1627 - Allow to set hibernate.dialect setting for pluggable database (#687) Optional property `database.hibernateDialect` which maps to `hibernate.dialect`. --- docs/source/changelog.rst | 2 ++ docs/source/corda-configuration-file.rst | 3 +++ .../net/corda/nodeapi/internal/persistence/CordaPersistence.kt | 3 ++- .../nodeapi/internal/persistence/HibernateConfiguration.kt | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/source/changelog.rst b/docs/source/changelog.rst index 89c54b5016..7f6cbe301f 100644 --- a/docs/source/changelog.rst +++ b/docs/source/changelog.rst @@ -37,6 +37,8 @@ Unreleased * Fixed node's behaviour on startup when there is no connectivity to network map. Node continues to work normally if it has all the needed network data, waiting in the background for network map to become available. +* Added `database.hibernateDialect` node configuration option + .. _changelog_r3_v3: R3 Corda 3.0 Developer Preview diff --git a/docs/source/corda-configuration-file.rst b/docs/source/corda-configuration-file.rst index 1c9c4f96d4..f7cf9e64b8 100644 --- a/docs/source/corda-configuration-file.rst +++ b/docs/source/corda-configuration-file.rst @@ -78,6 +78,9 @@ absolute path to the node's base directory. :schema: (optional) some database providers require a schema name when generating DDL and SQL statements. (the value is passed to Hibernate property 'hibernate.default_schema'). + :hibernateDialect: (optional) for explicit definition of ``hibernate.dialect`` property, for most cases Hibernate properly detect + the correct value + :dataSourceProperties: This section is used to configure the jdbc connection and database driver used for the nodes persistence. Currently the defaults in ``/node/src/main/resources/reference.conf`` are as shown in the first example. This is currently the only configuration that has been tested, although in the future full support for other storage layers will be validated. diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/CordaPersistence.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/CordaPersistence.kt index d084ba6182..7308fad8fa 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/CordaPersistence.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/CordaPersistence.kt @@ -35,7 +35,8 @@ data class DatabaseConfig( val runMigration: Boolean = false, val transactionIsolationLevel: TransactionIsolationLevel = TransactionIsolationLevel.REPEATABLE_READ, val schema: String? = null, - val exportHibernateJMXStatistics: Boolean = false + val exportHibernateJMXStatistics: Boolean = false, + val hibernateDialect: String? = null ) // This class forms part of the node config and so any changes to it must be handled with care diff --git a/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/HibernateConfiguration.kt b/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/HibernateConfiguration.kt index 6100ffd487..cbdf87b3f5 100644 --- a/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/HibernateConfiguration.kt +++ b/node-api/src/main/kotlin/net/corda/nodeapi/internal/persistence/HibernateConfiguration.kt @@ -90,6 +90,9 @@ class HibernateConfiguration( } config.setProperty("hibernate.default_schema", schemaName) } + databaseConfig.hibernateDialect?.apply { + config.setProperty("hibernate.dialect", this) + } schemas.forEach { schema -> // TODO: require mechanism to set schemaOptions (databaseSchema, tablePrefix) which are not global to session